Check a server whether has generated proxy before

@param  {Object}  client rpc client instance
@param  {Object}  sinfo  server info
@return {Boolean}        true or false
543199
function(client, sinfo) {
  let proxy = client.proxies;
  return !!proxy.sys && !! proxy.sys[sinfo.serverType];
}
723045
function isPortTaken(port, fn) {
  const net = require('net')
  const tester = net.createServer()
    .once('error', function (err) {
      if (err.code != 'EADDRINUSE') return fn(err)
      fn(null, true)
    })
    .once('listening', function() {
      tester.once('close', function() { fn(null, false) })
        .close()
    })
    .listen(port)
}
1203587
function _proxyRequest(json, callback) {
	  var rollbarProxy = new RollbarProxy();
	  rollbarProxy.sendJsonPayload(
	    json,
	    function(_msg) { /* do nothing */ }, // eslint-disable-line no-unused-vars
	    function(err) {
	      callback(new Error(err));
	    }
	  );
	}
643138
function startServer(argv, httpPort, httpsPort, certs) {
  console.log('Launching proxy server...');
  console.log('   http: ' + httpPort);
  console.log('  https: ' + httpsPort);

  // Injects a node stream by buffering all data, transforming it, and writing
  // it back out.
  // Module IDs are assigned on demand and rotate 0-126.
  var nextModuleId = 0;
  function injectStream(url, source, target) {
    var moduleId = nextModuleId++;
    if (nextModuleId >= 127) {
      nextModuleId = 0;
    }
    var sourceCode = '';
    source.on('data', function(chunk) {
      sourceCode += chunk;
    });
    source.on('end', function() {
      try {
        var targetCode = transformCode(moduleId, url, sourceCode, argv);
        target.end(targetCode);
      } catch (e) {
        console.log('Error during transformation, writing through.');
        console.log(e);
        target.end(sourceCode);
      }
    });
  };

  // Handles both HTTP and HTTPS requests.
  function handler(req, res) {
    // Support both the ?url= mode and the X-WTF-URL header.
    var targetUrl;
    if (req.headers['x-wtf-url']) {
      targetUrl = req.headers['x-wtf-url'];
    } else {
      var parsedUrl = url.parse(req.url, true);
      var query = parsedUrl.query;
      targetUrl = query.url;
    }
    if (!targetUrl || targetUrl.indexOf('http') != 0) {
      res.writeHead(404, ['Content-Type', 'text/plain']);
      res.end();
      return;
    }

    res.on('error', function(e) {
      console.log('ERROR (source): ' + e);
    });

    var targetModule = targetUrl.indexOf('https') == 0 ? https : http;
    targetModule.get(targetUrl, function(originalRes) {
      // Eat errors, otherwise the app will die.
      originalRes.on('error', function(e) {
        console.log('ERROR (target): ' + e);
      });

      // Pull out content type to see if we are interested in it.
      var supportedContentType = false;
      var contentType = originalRes.headers['content-type'];
      if (contentType && contentType.indexOf(';') != 0) {
        contentType = contentType.substr(0, contentType.indexOf(';'));
      }
      switch (contentType) {
        case 'text/javascript':
        case 'application/javascript':
          supportedContentType = true;
          break;
      }

      // Also parse the URL - some servers don't return content type for some
      // reason.
      var supportedPath = false;
      var contentUrl = url.parse(targetUrl);
      if (path.extname(contentUrl.pathname) == '.js') {
        supportedPath = true;
      }

      if (supportedContentType || supportedPath) {
        var headers = [];
        for (var key in originalRes.headers) {
          if (key == 'content-length') {
            continue;
          }
          headers.push([key, originalRes.headers[key]]);
        }
        res.writeHead(originalRes.statusCode, headers);
        injectStream(targetUrl, originalRes, res);
      } else {
        console.log('Pass-through: ' + targetUrl, contentType);
        res.writeHead(originalRes.statusCode, originalRes.headers);
        originalRes.pipe(res);
      }
    }).on('error', function(e) {
      console.log(e);
      res.writeHead(404, ['Content-Type', 'text/plain']);
      res.end(e.message);
    });
  };

  // HTTP server.
  var httpServer = http.createServer(handler);
  httpServer.listen(httpPort);

  // HTTPS server.
  var httpsServer = https.createServer({
    key: certs.privateKey,
    cert: certs.certificate
  }, handler);
  httpsServer.listen(httpsPort);

  console.log('Server ready, use ctrl-c to exit...');
  console.log('');
}
748337
public function checkRestrictedGrantType($client_id, $grant_type)
	{
		$client = $this->repo->find($client_id);

		if(!$client) {
			return false;
		}

		$restrictedTypes = $client->getRestrictedGrantTypes();

		// Null restricted type assuemd to be true.
		if(is_null($restrictedTypes)) {
			return true;
		}


		return in_array($grant_type, $restrictedTypes);
	}
381614
function proxyMethods(exec, query) {
    const methods = [].concat(END_POINT_METHODS).concat(CHAINABLE_METHODS);
    for (let name of methods) {
        const oldMethod = query[name];
        query[name] = function (...args) {
            const clonedQuery = query.clone();
            proxyMethods(exec, clonedQuery);
            oldMethod.apply(clonedQuery, args);
            if (CHAINABLE_METHODS.indexOf(name) > -1) {
                return clonedQuery;
            } else {
                return exec(clonedQuery.toString());
            }
        }
    }
}
541343
function RPCClient(options) {
  if (!(this instanceof RPCClient))
    return new RPCClient(options);

  if (!options)
    options = {};

  if (typeof options === 'string')
    options = { uri: options };

  this.options = options;
  this.network = Network.get(options.network);

  this.uri = options.uri || `http://localhost:${this.network.rpcPort}`;
  this.apiKey = options.apiKey;
  this.id = 0;
}
389932
function proxyOptsFromStr(str) {
    if (!str) {
        return (false);
    }

    var s = str;

    // Normalize: host:port -> http://host:port
    // FWIW `curl` supports using "http_proxy=host:port".
    if (!/^[a-z0-9]+:\/\//.test(s)) {
        s = 'http://' + s;
    }
    var parsed = url.parse(s);

    var proxyOpts = {
        protocol: parsed.protocol,
        host: parsed.hostname
    };

    if (parsed.port) {
        proxyOpts.port = Number(parsed.port);
    }

    if (parsed.auth) {
        proxyOpts.proxyAuth = parsed.auth;
    }

    return (proxyOpts);
}
1006889
def is_authenticated_with_proxy(proxy):
    """"""
    if proxy is None:
        return False
    elif proxy.has_authentication():
        return proxy.get_authentication().is_valid()
    else:
        return False
1112577
function rdRoute(client, serverType, msg, cb) {
    const servers = client._station.serversMap[serverType];
    if (!servers || !servers.length) {
        utils.invokeCallback(cb, new Error(`rpc servers not exist with serverType: ${serverType}`));
        return;
    }
    const index = Math.floor(Math.random() * servers.length);
    utils.invokeCallback(cb, null, servers[index]);
}
449425
def _should_proxy(self, attr):
        
        if attr in type(self).__notproxied__:
            return False
        if _oga(self, "__notproxied__") is True:
            return False
        return True
1155160
function ensureClient(client) {
  var err;

  if(!client) {
    // Likely close() was called and now another step is happening
    // when it shouldn't. Create and log an error, so we get a stack
    // and can see why it happened.
    err = new Error('expected this.client to exist');
    log.error(err);
  }

  // If we're in an unexpected state for syncing (i.e., not a sync step), log that
  switch(client.state) {
    case ServerStates.CREATED:
    case ServerStates.CLOSED:
    case ServerStates.CLOSING:
    case ServerStates.CONNECTING:
    case ServerStates.ERROR:
      log.warn({client: client}, 'Unexpected client state for sync protocol handling: %s', client.state);
      break;
  }

  return client;
}
1147147
function(x){
                var pqify = (proxyquireifyName != null) && cache[proxyquireifyName];
                // Only try to use the proxyquireify version if it has been `require`d
                if (pqify && pqify.exports._proxy) {
                    return pqify.exports._proxy(req, x);
                } else {
                    return req(x);
                }
            }
1373355
def proxyInit(self):
        
        # Call init() with local XML RPC config and interface_id (the name of
        # the receiver) to receive events. XML RPC server has to be running.
        for interface_id, proxy in self.proxies.items():
            if proxy._skipinit:
                continue
            if proxy._callbackip and proxy._callbackport:
                callbackip = proxy._callbackip
                callbackport = proxy._callbackport
            else:
                callbackip = proxy._localip
                callbackport = self._localport
            LOG.debug("ServerThread.proxyInit: init('http://%s:%i', '%s')" %
                      (callbackip, callbackport, interface_id))
            try:
                proxy.init("http://%s:%i" %
                           (callbackip, callbackport), interface_id)
                LOG.info("Proxy initialized")
            except Exception as err:
                LOG.debug("proxyInit: Exception: %s" % str(err))
                LOG.warning("Failed to initialize proxy")
                self.failed_inits.append(interface_id)
883649
public function isDoiAuthenticatedClients($doiValue, $client_id = null)
    {
        if ($client_id === null) {
            return false;
        }

        $client = $this->getAuthenticatedClient();

        if ($client->client_id != $client_id) {
            return false;
        }

        // everyone has access to test prefix
        if (strpos($doiValue, DOIServiceProvider::$globalTestPrefix) === 0) {
            return true;
        }

        // check if the client owns the prefix
        foreach ($client->prefixes as $clientPrefix) {
            if (strpos($doiValue, $clientPrefix->prefix->prefix_value) === 0) {
                return true;
            }
        }

        return false;
    }
717054
function ClientState(client) {

  /**
   * The associated client instance.
   *
   * @property client
   * @type Client
   */
  this.client = client;

  /**
   * The time (in milliseconds) to wait before the next request
   * may be sent to the API; this value is only updated upon
   * reception of a server response and thus valid only in
   * combination with the time of reception.
   *
   * @property retry
   * @type Number
   */
  this.retry = 0;

  /**
   * The time (in milliseconds) the client should back-off
   * before resuming normal API interactions; this value is
   * only updated upon reception of a server response and
   * thus valid only in combination with the time of reception.
   *
   * @property backoff
   * @type Number
   */
  this.backoff = 0;

  /**
   * The HTTP status code of the last response received
   * by the client.
   *
   * @property code
   * @type Number|null
   */
  this.code = null;

  /**
   * The UNIX timestamp of the last API response received
   * by the client.
   *
   * @property timestamp
   * @type Number
   */
  this.timestamp = Date.now();
}
317013
private boolean checkIfHostHasChanged(EventChannelStruct event_channel_struct) {
        boolean retVal = false;
        try {
            IORdump dump = new IORdump(event_channel_struct.adm_device_proxy);
            String server_host = dump.get_hostname();

            //	Keep server_host name without Fully Qualify Domain Name
            int idx = server_host.indexOf('.');
            if (idx > 0)
                server_host = server_host.substring(0, idx);

            if (!event_channel_struct.host.equals(server_host))
                retVal = true;
        } catch (DevFailed e) { /* */ }
        return retVal;
    }