Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 => {