Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'is-root' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
synopsis: [
'$ sudo dns-proxy-https -s 127.0.0.1 -p 1081',
'$ sudo dns-proxy-https -s 127.0.0.1 -p 1081 -f 114.114.114.114 -t 500000',
'$ sudo dns-proxy-https -s 127.0.0.1 -p 1081 -w whitelist.txt'
],
footer: 'Project home: [dns-proxy-https]{https://github.com/CodeFalling/dns-proxy-https}'
};
let option = cli.parse();
console.log(cli.getUsage(app));
// help end
// check sudo
if (!isRoot()) {
throw new Error('Please run dns-proxy-https with sudo!');
}
// read whitelist if existed
let whitelist = [];
if (option.whitelist_file) {
fs.readFile(option.whitelist_file, 'utf8', function (err, data) {
if (err) {
winston.info(err);
return;
}
whitelist = data.split('\n').filter(line => {
return line[0] !== '#'; // ignore comment
});
});
}
new Promise(resolve => {
if (port === defaultPort) {
return resolve(port);
}
const message =
process.platform !== 'win32' && defaultPort < 1024 && !isRoot()
? `Admin permissions are required to run a server on a port below 1024.`
: `Something is already running on port ${defaultPort}.`;
if (isInteractive) {
clearConsole();
const existingProcess = getProcessForPort(defaultPort);
const question = {
type: 'confirm',
name: 'shouldChangePort',
message: `${chalk.yellow(
`message${
existingProcess // eslint-disable-line
? ` Probably:\n ${existingProcess}`
: ''
}`,
)}\n\nWould you like to run the app on another port instead?`,
default: true,
new Promise(resolve => {
if (port === defaultPort) {
return resolve(port)
}
const message =
process.platform !== 'win32' && defaultPort < 1024 && !isRoot()
? `Admin permissions are required to run a server on a port below 1024.`
: `Something is already running on port ${defaultPort}.`
if (isInteractive) {
clearConsole()
const existingProcess = getProcessForPort(defaultPort)
const question = {
type: 'confirm',
name: 'shouldChangePort',
message:
chalk.yellow(
message +
`${existingProcess ? ` Probably:\n ${existingProcess}` : ''}`
) + '\n\nWould you like to run the app on another port instead?',
default: true,
}
inquirer.prompt(question).then(answer => {