method used to use an existing google vpc network
@returns {*}
183761
function useVpcNetwork(mCb) {
			//assign network name to deployment entry
			oneDeployment.options.network = name;
			
			function patchFirewall() {
				let firewallRules = getFirewallRules(oneDeployment.options.network);
				
				let request = getConnector(options.infra.api);
				request.filter = `network eq .*${oneDeployment.options.network}`;
				request.project = options.infra.api.project;
				
				//list firewalls
				//Ref: https://cloud.google.com/compute/docs/reference/rest/v1/firewalls/list
				v1Compute().firewalls.list(request, function (error, firewalls) {
					if (error) return mCb(error);
					
					if (!firewalls.items) firewalls.items = [];
					
					async.eachSeries(firewallRules, (oneRule, vCb) => {
						let foundFirewall = firewalls.items.find((oneEntry) => {
							return oneEntry.name === oneRule.name
						});
						
						if (foundFirewall) {
							options.soajs.log.debug("Firewall rule:", oneRule.name, "already exists, skipping");
							return vCb();
						} else {
							options.soajs.log.debug("Creating firewall rule:", oneRule.name);
							request.resource = oneRule;
							return v1Compute().firewalls.insert(request, vCb);
						}
					}, mCb);
				});
			}
			
			patchFirewall();
		}
441025
function Router() {
    var resources = {};

    // Public methods
    this.addRoute = function(resource) {
        var mPoint = resource.getMountPoint();

        if (typeof(resources[mPoint]) === 'undefined') {
            resources[mPoint] = resource;
        } else {
            resources[mPoint].update(resource);
        }
    };

    this.dispatch = function(locals) {
        var accept = locals.getAcceptedTypes();
        var request = locals.getRequest();
        var dispatched = false;
        var header;
        var mountPoint;
        var resource;

        locals.updateResponse(404);
        // Iterate over the resources
        for (mountPoint in resources) {
            // Did anybody flush already?
            resource = resources[mountPoint];
            // Does your URL definition matches this path?
            if (resource.matchesURL(request.path)) {
                locals.updateResponse(405);
                // Do you handle this method?
                if (resource.allowsMethod(request.method)) {
                    locals.updateResponse(406);
                    // Do you understand this format?
                    if (resource.acceptsType(accept, request.method)) {
                        locals.updateResponse(200);
                        // It's all yours
                        resource.takeOver(locals);
                        // And we set a flag announcing it was dispatched
                        dispatched = true;
                    }
                } else {
                    header = resource.getMethods().join(', ');
                    locals.getResponse().setHeader('Allow', header);
                }
            }
        }

        // Each resource emits a 'Resource:postRequest' event that flushes
        // the response. If no resource was found, that event was not emitted
        // and we need to do it manually.
        if (!dispatched) {
            locals.emit('Resource:completed');
            locals.emit('Resource:preRequest');
            locals.emit('Resource:postRequest');
        }
    };
}
454882
function buildVPCEndpoint(service, { routeTableIds = [], subnetIds = [] } = {}) {
  const endpoint = {
    Type: 'AWS::EC2::VPCEndpoint',
    Properties: {
      ServiceName: {
        'Fn::Join': [
          '.',
          [
            'com.amazonaws',
            {
              Ref: 'AWS::Region',
            },
            service,
          ],
        ],
      },
      VpcId: {
        Ref: 'VPC',
      },
    },
  };

  // @see https://docs.aws.amazon.com/vpc/latest/userguide/vpc-endpoints.html
  if (service === 's3' || service === 'dynamodb') {
    endpoint.Properties.VpcEndpointType = 'Gateway';
    endpoint.Properties.RouteTableIds = routeTableIds;
    endpoint.Properties.PolicyDocument = {
      Statement: [
        {
          Effect: 'Allow',
          /*
          TODO 11/21: We should restrict the VPC Endpoint to only the Lambda
          IAM role, but this doesn't work.

          Principal: {
            AWS: {
              'Fn::GetAtt': [
                'IamRoleLambdaExecution',
                'Arn',
              ],
            },
          }, */
          Principal: '*',
          Resource: '*',
        },
      ],
    };
    if (service === 's3') {
      endpoint.Properties.PolicyDocument.Statement[0].Action = 's3:*';
    } else if (service === 'dynamodb') {
      endpoint.Properties.PolicyDocument.Statement[0].Action = 'dynamodb:*';
    }
  } else {
    endpoint.Properties.VpcEndpointType = 'Interface';
    endpoint.Properties.SubnetIds = subnetIds;
    endpoint.Properties.PrivateDnsEnabled = true;
    endpoint.Properties.SecurityGroupIds = [
      {
        Ref: 'LambdaEndpointSecurityGroup',
      },
    ];
  }

  const parts = service.split(/[-_.]/g);
  parts.push('VPCEndpoint');
  const cfName = parts.map(part => part.charAt(0).toUpperCase() + part.slice(1)).join('');

  return {
    [cfName]: endpoint,
  };
}
621739
function NodeJsRTCObjectFactory() {

	this.createIceServers = function(urls, username, password) {
		return null;
	};

    this.createRTCSessionDescription = function(sessionDescriptionString) {
        return null;
    };

    this.createRTCIceCandidate = function(rtcIceCandidateString) {
        return null;
    };

    this.createRTCPeerConnection = function(config) {
    	return null;
    };
}
562664
function() {
    const query = {clientId};
    var   body  = sg.extend({partnerId, version, sessionId}, {rsvr});

    self.POST('hq', '/clientStart', query, body, function(err, config) {
      //console.log('clientStart-object', query, body, err, config);

      if (sg.ok(err, config)) {
        self.config = sg.deepCopy(config);

        _.each(self.config.upstreams, (upstream, prj_app) => {
          self.upstreams[prj_app] = upstream;
        });

        if (sg.verbosity() > 2) {
          _.each(self.upstreams, (upstream, prj_app) => {
            console.log(`Using upstream: ${sg.lpad(prj_app, 20)} ->> ${upstream}`);
          });
        }

        ctor_callback(err, self.config);
      }

    });
  }
965035
function Network(options) {
  if (!(this instanceof Network))
    return new Network(options);

  assert(!Network[options.type], 'Cannot create two networks.');

  this.type = options.type;
  this.seeds = options.seeds;
  this.magic = options.magic;
  this.port = options.port;
  this.checkpointMap = options.checkpointMap;
  this.lastCheckpoint = options.lastCheckpoint;
  this.checkpoints = [];
  this.halvingInterval = options.halvingInterval;
  this.genesis = options.genesis;
  this.genesisBlock = options.genesisBlock;
  this.pow = options.pow;
  this.block = options.block;
  this.bip30 = options.bip30;
  this.activationThreshold = options.activationThreshold;
  this.minerWindow = options.minerWindow;
  this.deployments = options.deployments;
  this.deploys = options.deploys;
  this.unknownBits = ~consensus.VERSION_TOP_MASK;
  this.keyPrefix = options.keyPrefix;
  this.addressPrefix = options.addressPrefix;
  this.requireStandard = options.requireStandard;
  this.rpcPort = options.rpcPort;
  this.minRelay = options.minRelay;
  this.feeRate = options.feeRate;
  this.maxFeeRate = options.maxFeeRate;
  this.selfConnect = options.selfConnect;
  this.requestMempool = options.requestMempool;
  this.time = new TimeData();

  this._init();
}
548775
function Router () {
  if (!(this instanceof Router)) return new Router();

  var index = 0;

  /**
   * @api public
   */

  function router () {
    router.route.apply(router, slice.call(arguments));
  }

  router.__proto__ = Router.prototype;

  /**
   * Inc the index
   *
   * @api private
   * @return Number
   */

  router.index = function () {
    return index++;
  };

  /**
   * Pushes the socket and arguments through the middleware
   *
   * @api public
   * @param {Error} err *optional
   * @param {Socket} socket
   * @param {Array} args
   * @param {Function} cb
   */

  router.route = function () {
    var args = slice.call(arguments);
    var name = '*';
    var err = null;
    var cb = function () { console.warn('default callback', slice.call(arguments)); };
    var end = function (err) { 
      if (cb.called) return;
      cb.called = new Date(); 
      cb.apply(cb, [err ? err : null].concat(args)); 
    };

    if ('string' === typeof args[0]) name = args.shift();
    if ('object' === typeof args[0] && args[0] instanceof Error) err = args.shift();
    if ('function' === typeof args[args.length - 1]) cb = args.pop();

    var i = 0, path = router.getPath(name), len = path.length;

    debug('got path the length is %s', len);

    (function step (err) {
      
      if (cb.called) return;

      debug('current step %s of %s', i+1, len);

      function next (err) {
        if (++i >= len) {
          end(err);
        }
        else {
          step(err);
        }
      }

      var fn = path[i];
      if (!fn) return next();

      try {
        if (err) {
          if (fn.err) {
            if (fn instanceof Router) {
              fn.route.apply(fn,[name, err].concat(args).concat(next).concat(end));
            }
            else {
              fn.apply(fn, [err].concat(args).concat(next).concat(end));
            }
          }
          else {
            next(err);
          }
        }
        else {
          if (fn.err) {
            next();
          }
          else {
            if (fn instanceof Router) {
              fn.route.apply(fn,[name].concat(args).concat(next).concat(end));
            }
            else {
              fn.apply(fn, args.concat(next).concat(end));
            }
          }
        }
      }
      catch(e) {
        debug('caught error %s', e);
        debug('the fn causing problems', fn);
        console.error(e.stack);
        next(e);
      }
      
    })(err);

  };
  
  return router;

}
894911
function _gpfLoadSources () { //jshint ignore:line
    var sourceListContent = _gpfSyncReadForBoot(gpfSourcesPath + "sources.json"),
        _gpfSources = _GpfFunc("return " + sourceListContent)(),
        allContent = [],
        idx = 0;
    for (; idx < _gpfSources.length; ++idx) {
        _gpfProcessSource(_gpfSources[idx], allContent);
    }
    return allContent.join("\n");
}
1029543
function createConnectionObject(context) {
  const { req } = context.bindings;
  const xForwardedFor = req.headers ? req.headers["x-forwarded-for"] : undefined;

  return {
    encrypted     : req.originalUrl && req.originalUrl.toLowerCase().startsWith("https"),
    remoteAddress : removePortFromAddress(xForwardedFor)
  };
}
345236
private PoolingHttpClientConnectionManager createConnectionMgr() {
        PoolingHttpClientConnectionManager connectionMgr;

        // prepare SSLContext
        SSLContext sslContext = buildSslContext();
        ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
        // we allow to disable host name verification against CA certificate,
        // notice: in general this is insecure and should be avoided in production,
        // (this type of configuration is useful for development purposes)
        boolean noHostVerification = false;
        LayeredConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
                sslContext,
                noHostVerification ? NoopHostnameVerifier.INSTANCE : new DefaultHostnameVerifier()
        );
        Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory>create()
                .register("http", plainsf)
                .register("https", sslsf)
                .build();
        connectionMgr = new PoolingHttpClientConnectionManager(r, null, null,
                null, connectionPoolTimeToLive, TimeUnit.SECONDS);

        connectionMgr.setMaxTotal(maxConnectionsTotal);
        connectionMgr.setDefaultMaxPerRoute(maxConnectionsPerRoute);
        HttpHost localhost = new HttpHost("localhost", 80);
        connectionMgr.setMaxPerRoute(new HttpRoute(localhost), maxConnectionsPerRoute);
        return connectionMgr;
    }
1014152
function() {
    var self = this;
    // Unfortunately we can't use a connect middleware here since
    // sockjs installs itself prior to all existing listeners
    // (meaning prior to any connect middlewares) so we need to take
    // an approach similar to overshadowListeners in
    // https://github.com/sockjs/sockjs-node/blob/cf820c55af6a9953e16558555a31decea554f70e/src/utils.coffee
    _.each(['request', 'upgrade'], function(event) {
      var httpServer = WebApp.httpServer;
      var oldHttpServerListeners = httpServer.listeners(event).slice(0);
      httpServer.removeAllListeners(event);

      // request and upgrade have different arguments passed but
      // we only care about the first one which is always request
      var newListener = function(request /*, moreArguments */) {
        // Store arguments for use within the closure below
        var args = arguments;

        // Rewrite /websocket and /websocket/ urls to /sockjs/websocket while
        // preserving query string.
        var parsedUrl = url.parse(request.url);
        if (parsedUrl.pathname === pathPrefix + '/websocket' ||
            parsedUrl.pathname === pathPrefix + '/websocket/') {
          parsedUrl.pathname = self.prefix + '/websocket';
          request.url = url.format(parsedUrl);
        }
        _.each(oldHttpServerListeners, function(oldListener) {
          oldListener.apply(httpServer, args);
        });
      };
      httpServer.addListener(event, newListener);
    });
  }
413771
async function searchConnNameFromIP(ip) { // eslint-disable-line no-unused-vars
    const connNames = await listConnectionNames();
    const gipnum = ipv4.convToNum(ip);
    for (const connName of connNames) {
        const cmd = [
            'nmcli', '-f', 'IP4.ADDRESS', 'connection', 'show', connName,
        ];
        const output = await executeCommand(cmd);
        for (const line of output.split('\n')) {
            const re = line.match(/\s+([\d\.]+)\/([\d]+)/);
            if (!re) {
                continue;
            }
            const ip = ipv4.convToNum(re[1]);
            const mask = parseInt(re[2]);
            if ((ip & mask) == (gipnum & mask)) {
                return connName;
            }
        }
    }
    return null;
}
9627
function(hostname, callback) {
  get_nodes(function(err,nodes) {
    if (err) return callback(err);

    var n = nodes.filter(function(node) {
      return node.name === hostname;
    });

    callback(null,(n.length === 1) ? n[0].ip_address : null);
  });
}
1297695
function ProxyGuest ( options ) {
	// prepare
	var name;

	// connection with server
	this.active = false;

	/**
	 * proxy instance configuration
	 * @namespace
	 */
	this.config = {
		// node.js server address
		host: '127.0.0.1',

		// http server port
		port: 8800,

		// session name
		name: 'anonymous',

		// cached url for posting requests
		urlPost: '',

		// cached url for info collecting
		urlInfo: ''
	};

	// single ajax object for performance
	this.xhr = new XMLHttpRequest();

	// validate and iterate input
	if ( options && typeof options === 'object' ) {
		for ( name in options ) {
			// rewrite defaults
			if ( options.hasOwnProperty(name) ) {
				this.config[name] = options[name];
			}
		}
	}

	// there may be some special chars
	name = encodeURIComponent(this.config.name);

	// cache final request urls
	this.config.urlPost = 'http://' + this.config.host + ':' + this.config.port + '/' + name;
	this.config.urlInfo = 'http://' + this.config.host + ':' + this.config.port + '/info/' + name;

	// check initial connection status
	this.active = this.info().active;

	console.log('%c[core]\t%c%s\t%c0\t%cconnection to the host %c(%s:%s): %c%s',
		'color:grey',
		'color:purple', this.config.name,
		'color:grey',
		'color:black',
		'color:grey', this.config.host, this.config.port,
		'color:' + (this.active ? 'green' : 'red'), this.active ? 'available' : 'not available'
	);
}
120199
function getUrl(remoteName){
    const gitInfo = getGitInfo();
    return remoteName ? getRepoRemoteUrl(gitInfo, remoteName) : getAllRemotesUrls(gitInfo);
}
1269131
function newClientStub() {
    // First create the appropriate TLS certs with dgraph cert:
    //     $ dgraph cert
    //     $ dgraph cert -n localhost
    //     $ dgraph cert -c user
    const rootCaCert = fs.readFileSync(path.join(__dirname, 'tls', 'ca.crt'));
    const clientCertKey = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.key'));
    const clientCert = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.crt'));
    return new dgraph.DgraphClientStub(
        "localhost:9080",
        grpc.credentials.createSsl(rootCaCert, clientCertKey, clientCert));
}
825548
function getNetwork(network) {
    // No network (null)
    if (network == null) {
        return null;
    }
    if (typeof (network) === 'number') {
        for (var name_1 in networks) {
            var n_1 = networks[name_1];
            if (n_1.chainId === network) {
                return {
                    name: n_1.name,
                    chainId: n_1.chainId,
                    ensAddress: (n_1.ensAddress || null),
                    _defaultProvider: (n_1._defaultProvider || null)
                };
            }
        }
        return {
            chainId: network,
            name: 'unknown'
        };
    }
    if (typeof (network) === 'string') {
        var n_2 = networks[network];
        if (n_2 == null) {
            return null;
        }
        return {
            name: n_2.name,
            chainId: n_2.chainId,
            ensAddress: n_2.ensAddress,
            _defaultProvider: (n_2._defaultProvider || null)
        };
    }
    var n = networks[network.name];
    // Not a standard network; check that it is a valid network in general
    if (!n) {
        if (typeof (network.chainId) !== 'number') {
            errors.throwError('invalid network chainId', errors.INVALID_ARGUMENT, { arg: 'network', value: network });
        }
        return network;
    }
    // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155)
    if (network.chainId !== 0 && network.chainId !== n.chainId) {
        errors.throwError('network chainId mismatch', errors.INVALID_ARGUMENT, { arg: 'network', value: network });
    }
    // Standard Network (allow overriding the ENS address)
    return {
        name: network.name,
        chainId: n.chainId,
        ensAddress: (network.ensAddress || n.ensAddress || null),
        _defaultProvider: (network._defaultProvider || n._defaultProvider || null)
    };
}