How to use the ip.address function in ip

To help you get started, we’ve selected a few ip 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 sysgears / larix / packages / zen / src / plugins / WebpackPlugin.ts View on Github external
// eslint-disable-next-line @typescript-eslint/camelcase
              keep_fnames: true
            }
          };
        }
        const UglifyJsPlugin = builder.require('uglifyjs-webpack-plugin');
        plugins.push(new UglifyJsPlugin(uglifyOpts));
      }
      plugins.push(new webpack.optimize.ModuleConcatenationPlugin());
    }
  }

  const backendOption = builder.backendUrl;
  const defines: any = {};
  if (backendOption) {
    defines.__BACKEND_URL__ = `'${backendOption.replace('{ip}', ip.address())}'`;
  }

  if (builder.require.probe('clean-webpack-plugin')) {
    const CleanWebpackPlugin = builder.require('clean-webpack-plugin');
    plugins = plugins.concat(new CleanWebpackPlugin(builder.buildDir));
  }

  if (stack.hasAny('dll')) {
    const name = getDllName(builder);
    plugins = [
      new webpack.DefinePlugin({
        'process.env.NODE_ENV': `"${buildNodeEnv}"`,
        ...defines,
        ...builder.defines
      }),
      new webpack.DllPlugin({
github laomu1988 / koa2-proxy / src / listen.js View on Github external
module.exports = function (_config, callback) {
    if (typeof _config == 'number') {
        _config = {
            port: _config
        }
    }
    config = Object.assign(config, _config);
    var proxy = this;
    var app = proxy.app;
    var httpServer = http.createServer(app.callback());
    proxy.httpServer = httpServer;
    proxy.port = config.port;
    proxy.localip = ip.address();
    proxy.localhost = proxy.localip + ':' + config.port;

    if (config.https) {
        // 下载cert证书
        proxy.when({
            fullUrl: config.loadCertUrl
        }, function (ctx) {
            ctx.logger.notice('Load Cert!');
            ctx.response.status = 200;
            ctx.response.body = config.cert;
            ctx.response.header['content-type'] = 'application/x-x509-ca-cert';
        });

        // 添加https代理服务
        if (config.cert && config.key) {
            let cxnEstablished = new Buffer(`HTTP/1.1 200 Connection Established\r\n\r\n`, 'ascii');
github amark / gun / test / axe / holy-grail.js View on Github external
/**
 * AXE test 1
 * What we want here: (1) Superpeer and (n) peers
 *  - The peers receives only the requested data.
 *  - If the Superpeer crash, after restart, must recreate all subscriptions and update the peers.
 *  - If some peer crash or go offline, must receive the changes via RTC.
 *
 * Tip: to run this `npm run testaxe`
 * Tip 2: if you clone the gun repo, you need to create a link do gun package. Do `npm install && cd node_modules && ln -s ../ gun`
 * Tip 3: If you not in localhost, run the browsers in anonymous mode because of domain security policies. https://superuser.com/questions/565409/how-to-stop-an-automatic-redirect-from-http-to-https-in-chrome
 */
var config = {
	IP: require('ip').address(),
	port: 8765,
	servers: 2,
	browsers: 3,
	route: {
		'/': __dirname + '/index.html',
		'/gun.js': __dirname + '/../../gun.js',
		'/gun/axe.js': __dirname + '/../../axe.js',
		'/gun/lib/radix.js': __dirname + '/../../lib/radix.js',
		'/gun/lib/webrtc.js': __dirname + '/../../lib/webrtc.js',
		'/jquery.js': __dirname + '/../../examples/jquery.js'
	}
}
var panic = require('panic-server');
panic.server().on('request', function(req, res){
	config.route[req.url] && require('fs').createReadStream(config.route[req.url]).pipe(res);
}).listen(config.port);
github Samsung / Wits / app.js View on Github external
function setBaseJSData() {
    try {
        let file = path.resolve(path.join('tizen','js','base.js'));
        let data = fs.readFileSync(file,'utf8');
        let contentSrc = getContentSrc();
        let contentFullSrc = isRemoteUrl(contentSrc)? contentSrc : (witsAppPath + '/' + contentSrc.replace(REG_FISRT_BACKSLASH,''));
        let convertData = {
            '{{HOST_CONTENT_PATH}}': witsAppPath,
            '{{HOST_IP}}': 'http://'+ip.address(),
            '{{HOST_PORT}}': socketPort,
            '{{HOST_CONTENT_SRC}}': contentFullSrc
        };

        let str = data.replace(REG_HOST_DATA, (key) => {
            return convertData[key];
        });

        fs.writeFileSync(path.join('tizen','js','main.js'), str, 'utf8');
    }
    catch(e) {
        console.log('Failed to set Wits baseJS data to file');
        process.exit(0);
    }
}
github smolleyes / node-upnp-client / lib / client.js View on Github external
'use strict'

var ssdp = require('node-ssdp'),
  xmlParser = require('xmldoc'),
  EE = require('events').EventEmitter,
  util = require('util'),
  dgram = require('dgram'),
  ip = require('ip'),
  http = require('http'),
  __ = require('underscore');
 
var PORT = 1900;
var HOST = ip.address();

function upnpClient() {
  var self = this

  if (!(this instanceof upnpClient)) return new upnpClient()

  EE.call(self)
  
  this._init()
  
}

util.inherits(upnpClient, EE)

upnpClient.prototype._init = function () {
    this._client = dgram.createSocket('udp4')
github zubairq / pilot / visifile / src / vf.js View on Github external
function getListOfHosts(callbackFn) {
    var serversToTry = [
                           "visifile.com"  ,
                           ip.address() + ":" +  80,
                           ip.address() + ":" +  3000,
                           "127.0.0.1:80"
                       ]

    lsFn(serversToTry, 0, function(serversReturned) {
        callbackFn(serversReturned)
    })
}
github nuxt / nuxt.js / packages / server / src / listener.js View on Github external
computeURL () {
    const address = this.server.address()
    if (!this.socket) {
      switch (address.address) {
        case '127.0.0.1': this.host = 'localhost'; break
        case '0.0.0.0': this.host = ip.address(); break
      }
      this.port = address.port
      this.url = `http${this.https ? 's' : ''}://${this.host}:${this.port}${this.baseURL}`
      return
    }
    this.url = `unix+http://${address}`
  }
github frctl / fractal / packages / internals / server / src / server.js View on Github external
get ip() {
    return `http://${ip.address()}:${this.port}`;
  }
github FFF-team / earth-scripts / tools.js View on Github external
const getLocalMockPort = (proxy) => {

    const ip = require('ip').address().replace(/\./g, '\\.');

    const proxyMatch = new RegExp(`https*://(localhost|127\\.0\\.0\\.1|${ip}):(\\d+)`).exec(proxy);

    return proxyMatch ? proxyMatch[2] : ''

};