How to use the hostile.set function in hostile

To help you get started, we’ve selected a few hostile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JarvusInnovations / emergence / kernel-lib / sites.js View on Github external
return;
                }
            }

            // apply existing site's properties in
            _.defaults(requestData, me.sites[request.path[1]]);
        }

        // create new site
        try {
            cfgResult = me.writeSiteConfig(requestData);

            if (cfgResult.isNew) {
                // write primary hostname to /etc/hosts
                if (me.options.localhost) {
                    hostile.set(me.options.localhost, cfgResult.site.primary_hostname);
                    console.log('added ' + cfgResult.site.primary_hostname + ' to /etc/hosts');
                }

                // notify plugins
                me.emit('siteCreated', cfgResult.site, requestData, {
                    databaseReady: function () {
                        // execute onSiteCreated within site's container
                        console.log('Executing Site::onSiteCreated() via php-cli');
                        phpProc = spawn(phpShellScript, [cfgResult.site.handle]);

                        phpProc.stdout.on('data', function (data) { console.log('php-cli stdout: ' + data); });
                        phpProc.stderr.on('data', function (data) { console.log('php-cli stderr: ' + data); });

                        function _phpExec (code) {
                            //console.log('php> '+code);
                            phpProc.stdin.write(code+'\n');
github me-box / databox / src / sethosts.js View on Github external
p = p.then(() => new Promise((resolve, reject) => {
		// TODO: Are we sure they map to those IPs on Linux? Should precede with docker inspect?
		var ip = process.platform === 'linux' ? '172.17.0.' + (2 + i) : '127.0.0.1';
		hostile.set(ip, host, (err) => err ? reject(err) : resolve());
	}));
});
github DylanPiercey / auto-sni / test / main.js View on Github external
ngrok.connect({ port: server.http.address().port }, function (err, url) {
        if (err) return t.fail(err)
        var host = url.replace('https://', '')

        hostile.set('127.0.0.1', host, function (err) {
          if (err) return t.fail(err)
          request(url + ':' + server.address().port)
            .get('/')
            .end(function (err, res) {
              if (err) return t.fail(err)
              t.equal(res.text, 'Hello World\n', 'should respond to https request')
              ngrok.disconnect(url)
              server.close()
              hostile.remove('127.0.0.1', host)
            })
        })
      })
    })
github bbeldame / local.dev / index.js View on Github external
activatePortForwarding(minIp, port).then(() => {
        hostile.set('# local.dev', port);
        hostile.set(minIp, url);
        console.log(chalk.green(`
Added local.dev :
localhost:${chalk.green(`${port} <-`)} ${chalk.green(url)}
        `));
      });
    });
github 10up / wp-local-docker-v2 / hosts.js View on Github external
const add = function( hosts ) {
    hostile.set( '127.0.0.1', hosts.join(' '), function( err ) {
        if (err) {
            console.error(err)
        } else {
            console.log('Added to hosts file successfully!')
        }
    });
};
github leftstick / hosts-high / src / renderer / stores / useHostsModel.js View on Github external
hostile.get(false, (err, lines) => {
          const isDefined = lines.some(line => line[0] === host.ip && line[1] === host.domain)
          if (isDefined) {
            return reject(`host [${host.ip} ${host.domain}] has been used`)
          }

          hostile.set(host.ip, host.domain, err => {
            if (err) {
              return reject(`Failed to add [${host.ip} ${host.domain}]: ${err.message}`)
            }
            if (host.alias) {
              setAliases({ ...aliases, [host.ip + host.domain]: host.alias })
            }
            setSysHosts(sysHosts => [...sysHosts, { ...host, disabled: false, alias: aliases[host.ip + host.domain] }])
            resolve()
          })
        })
      })
github giuseppeg / ffocus / bin / ffocus.js View on Github external
sites.forEach(site => {
    try {
      hostile.set('127.0.0.1', site)
      log(`🚫  Blocking ${site}`)
    } catch(err) {
      error(err.message, true)
    }
  })
github pixelcollective / gardener / config / gardener / tasks / vhost.js View on Github external
exports.configure = (config, err) => {
  const tasks = [
    {
      label: 'Setting rule in /etc/hosts',
      command: hostile.set('127.0.0.1', config.testHost),
    },
  ];
  doTasks('Configure vhost ❖', ' Configure vhost', tasks, err, true);
}
github xiaojue / fd-server / server / hosts.js View on Github external
queue.push(function (cb){
        hostile.set(ip || '127.0.0.1', domain, function (err) {
            if (err) {
                logger.error(err)
            } else {
                logger.info('set hosts successfully! ' + domain)
            }
            cb();
        });
    });
    deal();
github leftstick / hosts-high / src / helpers / hostsControl.js View on Github external
return new Promise((resolve, reject) => {
        hostile.set(host.ip, host.domain, err => {
          if (err) {
            return reject(
              'failed adding ' + host.ip + '\n\n Please Make sure you have permission to modify ' + HOSTS + ' file'
            )
          }
          if (host.alias) {
            localStorage.setItem(ALIAS_PREFIX + host.ip + host.domain, host.alias)
          }
          host.disabled = false
          resolve(host)
        })
      })
    })

hostile

Simple /etc/hosts manipulation

MIT
Latest version published 4 months ago

Package Health Score

72 / 100
Full package analysis