query info for a server, returns server in the format of {IP: 'string', port: 'number} undefined if no servers found
516674
function (server_name, onDone) {

	// check if cached server info exists	
	if (l_servers.hasOwnProperty(server_name)) {
		var server = l_servers[server_name];
		
		LOG.warn('cache exists: ', 'Entry');
		LOG.warn(server, 'Entry');
		UTIL.safeCall(onDone, server);
	}
	else {
		
		// seek server IP/port info from monitor
		//l_queryServer(server_name, function (result) {
		//SR.Script['handler'].queryServer(server_name, function (result) {
		//g_handler.queryServer(server_name, function (result) {
		SR.API.queryServer({name: server_name}, function (err, result) {
			
			if (err) {
				return LOG.error(err);	
			}
			
			if (result && result.length > 0) {
				// TODO: pick a random one if more than one choices OR choose based on loading?
				var index = UTIL.randInteger(result.length);
				var info = result[index];
			
				var server = {IP: info.IP, port: info.port}
				l_servers[server_name] = server;
				onDone(server);
			}
			else
				onDone();
		});
	}	
}
25241
def get_server_info(self):
        
        response = self.get_proto(path='')
        message = rest_pb2.GetApiOverviewResponse()
        message.ParseFromString(response.content)
        return ServerInfo(message)
889811
function ip() {
    let network = os.networkInterfaces(),
        keys = Object.keys(network),
        ips = [];

    for (let key of keys) {
        network[key].forEach(ip => {
            ip.family === 'IPv4' && !ip.internal && ips.push(ip.address);
        });
    }

    return ips.length ? ips[0] : '127.0.0.1';
}
1229771
def run(self):
        

        logging.debug("Querying server {0}".format(self.server['ip']))

        try:
            # Create a DNS resolver query
            rsvr = dns.resolver.Resolver()
            rsvr.nameservers = [self.server['ip']]
            rsvr.lifetime = 5
            rsvr.timeout = 5

            qry = rsvr.query(self.domain, self.recType)

            # Get the results, sort for consistancy
            results = sorted([r.to_text() for r in qry])
            success = True
        # Handle all the various exceptions
        except dns.resolver.NXDOMAIN:
            success = False
            results = ['NXDOMAIN']
        except dns.resolver.NoNameservers:
            success = False
            results = ['No Nameservers']
        except dns.resolver.NoAnswer:
            success = False
            results = ['No Answer']
        except dns.resolver.Timeout:
            success = False
            results = ['Server Timeout']

        # Save the results
        self.result = {
            'server': self.server,
            'results': results,
            'success': success
        }
1155732
def get_external_ip(self):
        

        random.shuffle(self.server_list)
        myip = ''
        for server in self.server_list[:3]:
            myip = self.fetch(server)
            if myip != '':
                return myip
            else:
                continue
        return ''
1125815
function getServer(client, type, server, port, cb) {
    var serverType    = type || 'chat';
    var serverAddress = server || null;
    var serverPort    = port || 443;

    if (serverAddress === null) {
        var serverTypes = ['chat', 'events', 'groups'];
        if (serverTypes.indexOf(serverType) === -1) {
            serverType = 'chat';
        }

        var serverPortsChat = [80, 443, 6667];
        var serverPorts     = [80, 443];
        if (serverType === 'chat' && serverPortsChat.indexOf(serverPort) === -1) {
            serverPort = 443;
        } else if (serverType !== 'chat' && serverPorts.indexOf(serverPort) === -1) {
            serverPort = 443;
        }

        function findServer(cb) {
            function scan() {
                var serverAddr = serverList[serverType][serverPort][Math.floor(Math.random() * (serverList[serverType][serverPort].length))];
                if (unavailable.indexOf(serverAddr) >= 0) {
                    scan();
                } else {
                    probeServer(serverAddr, serverPort, function (err, available) {
                        if (!available || err) {
                            unavailable.push(serverAddr);
                            if (unavailable.length > serverList[serverType][serverPort].length-1) {
                                unavailable = [];
                                setTimeout(function(){
                                    if (!client.connected) { scan(); }
                                }, 60000);
                            } else {
                                return scan();
                            }
                        } else {
                            unavailable = [];
                            return cb(serverAddr);
                        }
                    });
                }
            }
            scan();
        }

        client.logger.info('Searching for a Twitch server..');
        findServer(function(server) {
            if (server) {
                cb(server + ':' + serverPort);
            }
        });
    }
    return cb(serverAddress + ':' + serverPort);
}
736074
function getHostname(origUrl?: string): null | string {
  const url = getUrlParts(origUrl);
  if (!url) {
    return null;
  }
  const port = url.port ? `:${url.port}` : "";
  return `${url.hostname}${port}`;
}
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);
  });
}
1261374
def server_exists(s_name, ip=None, s_state=None, **connection_args):
    '''
    
    '''
    server = _server_get(s_name, **connection_args)
    if server is None:
        return False
    if ip is not None and ip != server.get_ipaddress():
        return False
    if s_state is not None and s_state.upper() != server.get_state():
        return False
    return True
45052
function ServerDetails(x) {
    if (!(this instanceof ServerDetails)) return new ServerDetails(x);
    const v = x.split(':');
    this.hostname = (v[0].length > 0) ? v[0] : '';
    this.port = (v.length > 1) ? Number(v[1]) : 80;
}
691907
def query(method='servers', server_id=None, command=None, args=None,
          http_method='GET', root='api_root'):
    ''' 
    '''

    if root == 'api_root':
        default_url = 'https://cp-par1.scaleway.com'
    else:
        default_url = 'https://api-marketplace.scaleway.com'

    base_path = six.text_type(config.get_cloud_config_value(
        root,
        get_configured_provider(),
        __opts__,
        search_global=False,
        default=default_url
    ))

    path = '{0}/{1}/'.format(base_path, method)

    if server_id:
        path += '{0}/'.format(server_id)

    if command:
        path += command

    if not isinstance(args, dict):
        args = {}

    token = config.get_cloud_config_value(
        'token', get_configured_provider(), __opts__, search_global=False
    )

    data = salt.utils.json.dumps(args)

    request = __utils__["http.query"](path,
                                      method=http_method,
                                      data=data,
                                      status=True,
                                      decode=True,
                                      decode_type='json',
                                      data_render=True,
                                      data_renderer='json',
                                      headers=True,
                                      header_dict={'X-Auth-Token': token,
                                                   'User-Agent': "salt-cloud",
                                                   'Content-Type': 'application/json'})
    if request['status'] > 299:
        raise SaltCloudSystemExit(
            'An error occurred while querying Scaleway. HTTP Code: {0}  '
            'Error: \'{1}\''.format(
                request['status'],
                request['error']
            )
        )

    # success without data
    if request['status'] == 204:
        return True

    return salt.utils.json.loads(request['body'])
719787
def server(self):
        
        server = [s for s in self._server.resources() if s.clientIdentifier == self.machineIdentifier]
        if len(server) == 0:
            raise NotFound('Unable to find server with uuid %s' % self.machineIdentifier)
        return server[0]
1263802
def _build_query(self, ip_address):
        
        return '{}.{}.{}'.format(
            self.key, self._reverse_ip(ip_address), DNSBL_SUFFIX)
897819
function Server(options) {
  var self = this;
  options = options || {};

  self.serverVersion = '2.0.2';
  self.authKey = "";
  self.protocolVersion = protodef.VersionDummy.Version.V1_0;
  self.minProtocolVersion = 0;
  self.maxProtocolVersion = 0;
  self.port = options['driver-port'] || 28015;

  self._connections = {};
  self.nextConnectionId = 0;

  if (options.debug === true) {
    util._debug = true;
  }
  self.silent = options.silent || constants.SILENT || false;

  self.databases = {};
  self.init();
  self.id = util.uuid();
  self.name = options.name || os.hostname()+util.s4().slice(1);

  self._server = self._createServer();
}
924703
def get_server_info(self, anonymous = True):
		
		if anonymous == True:
			logger.debug('Getting server info via Anonymous BIND on server %s' % self.target_server.get_host())
			server = Server(self.target_server.get_host(), use_ssl=self.target_server.is_ssl(), get_info=ALL)
			conn = Connection(server, auto_bind=True)
			logger.debug('Got server info')
		else:
			logger.debug('Getting server info via credentials supplied on server %s' % self.target_server.get_host())
			server = Server(self.target_server.get_host(), use_ssl=self.target_server.is_ssl(), get_info=ALL)
			if self.use_sspi == True:
				conn = self.monkeypatch()
			else:
				conn = Connection(self._srv, user=self.login_credential.get_msuser(), password=self.login_credential.get_password(), authentication=self.login_credential.get_authmethod())
			logger.debug('Performing BIND to server %s' % self.target_server.get_host())
			if not self._con.bind():
				if 'description' in self._con.result:
					raise Exception('Failed to bind to server! Reason: %s' % conn.result['description'])
				raise Exception('Failed to bind to server! Reason: %s' % conn.result)
			logger.debug('Connected to server!')
		return server.info
662494
def DbGetServerInfo(self, argin):
        
        self._log.debug("In DbGetServerInfo()")
        return self.db.get_server_info(argin)
744047
async function ip(options = {}) {
  const {
    host = 'https://api.ipify.org',
  } = options
  const res = await rqt(host)
  return res
}