Adjust host parameters depending on exchange specific parameters
336866
private static void concludeHostParams(ExchangeSpecification exchangeSpecification) {

    if (exchangeSpecification.getExchangeSpecificParameters() != null) {
      if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Sandbox").equals(true)) {

        exchangeSpecification.setSslUri("https://api-public.sandbox.pro.coinbase.com");
        exchangeSpecification.setHost("api-public.sandbox.pro.coinbase.com");
      }
    }
  }
845002
def _convert_port_bindings(self, value):
        
        converted = {}

        if not value:
            return converted

        if isinstance(value, list):
            value = self._convert_port_bindings_from_list(value)

        if isinstance(value, dict):
            for port_protocol, host_bindings in six.iteritems(value):
                if '/' in port_protocol:
                    port, protocol = port_protocol.split('/')

                    if protocol not in ('tcp', 'udp'):
                        raise ValueError('only supported protocols are tcp and udp. {0} was passed.'.format(protocol))
                else:
                    port_protocol = "{0}/tcp".format(port_protocol)

                converted[port_protocol] = []

                if isinstance(host_bindings, list):
                    for host_binding in host_bindings:
                        if isinstance(host_binding, dict):
                            if "host_port" not in host_binding:
                                raise ValueError("host_port must be provided.")

                            if 'host_ip' not in host_binding:
                                host_binding['host_ip'] = ''

                            converted[port_protocol].append(host_binding)
                        else:
                            raise TypeError("The host binding information must be a dict.")
                else:
                    raise TypeError("The host binding information in port bindings must be in a list.")

        return converted
38634
function normalizeNetAddress (array) {
  return array.map(function (options) {
    if (typeof options === 'string') return wrapIPv6Address(options)
    if (typeof options === 'number') return wrapIPv6Address(defaultHost, options)
    options.host = options.host || defaultHost
    options.port = options.port || defaultPort
    return wrapIPv6Address(options.host, options.port)
  })
}
352689
function getDefaultSiteSettings(hostname) {
  const name = _.takeRight(hostname.split('.'), 2)[0]; // penultimate or last

  return {
    slug: name.toLowerCase(),
    name: _.startCase(name),
    host: hostname,
    path: '/',
    prefix: hostname,
    assetDir: 'public'
  };
}
879336
private void processConfig(final HttpServerExchange exchange, final RequestData requestData) {

        // Get the node builder
        List<String> hosts = null;
        List<String> contexts = null;
        final Balancer.BalancerBuilder balancer = Balancer.builder();
        final NodeConfig.NodeBuilder node = NodeConfig.builder(modCluster);
        final Iterator<HttpString> i = requestData.iterator();
        while (i.hasNext()) {
            final HttpString name = i.next();
            final String value = requestData.getFirst(name);

            UndertowLogger.ROOT_LOGGER.mcmpKeyValue(name, value);
            if (!checkString(value)) {
                processError(TYPESYNTAX, SBADFLD + name + SBADFLD1, exchange);
                return;
            }

            if (BALANCER.equals(name)) {
                node.setBalancer(value);
                balancer.setName(value);
            } else if (MAXATTEMPTS.equals(name)) {
                balancer.setMaxRetries(Integer.parseInt(value));
            } else if (STICKYSESSION.equals(name)) {
                if ("No".equalsIgnoreCase(value)) {
                    balancer.setStickySession(false);
                }
            } else if (STICKYSESSIONCOOKIE.equals(name)) {
                balancer.setStickySessionCookie(value);
            } else if (STICKYSESSIONPATH.equals(name)) {
                balancer.setStickySessionPath(value);
            } else if (STICKYSESSIONREMOVE.equals(name)) {
                if ("Yes".equalsIgnoreCase(value)) {
                    balancer.setStickySessionRemove(true);
                }
            } else if (STICKYSESSIONFORCE.equals(name)) {
                if ("no".equalsIgnoreCase(value)) {
                    balancer.setStickySessionForce(false);
                }
            } else if (JVMROUTE.equals(name)) {
                node.setJvmRoute(value);
            } else if (DOMAIN.equals(name)) {
                node.setDomain(value);
            } else if (HOST.equals(name)) {
                node.setHostname(value);
            } else if (PORT.equals(name)) {
                node.setPort(Integer.parseInt(value));
            } else if (TYPE.equals(name)) {
                node.setType(value);
            } else if (REVERSED.equals(name)) {
                continue; // ignore
            } else if (FLUSH_PACKET.equals(name)) {
                if ("on".equalsIgnoreCase(value)) {
                    node.setFlushPackets(true);
                } else if ("auto".equalsIgnoreCase(value)) {
                    node.setFlushPackets(true);
                }
            } else if (FLUSH_WAIT.equals(name)) {
                node.setFlushwait(Integer.parseInt(value));
            } else if (MCMPConstants.PING.equals(name)) {
                node.setPing(Integer.parseInt(value));
            } else if (SMAX.equals(name)) {
                node.setSmax(Integer.parseInt(value));
            } else if (TTL.equals(name)) {
                node.setTtl(TimeUnit.SECONDS.toMillis(Long.parseLong(value)));
            } else if (TIMEOUT.equals(name)) {
                node.setTimeout(Integer.parseInt(value));
            } else if (CONTEXT.equals(name)) {
                final String[] context = value.split(",");
                contexts = Arrays.asList(context);
            } else if (ALIAS.equals(name)) {
                final String[] alias = value.split(",");
                hosts = Arrays.asList(alias);
            } else if(WAITWORKER.equals(name)) {
                node.setWaitWorker(Integer.parseInt(value));
            } else {
                processError(TYPESYNTAX, SBADFLD + name + SBADFLD1, exchange);
                return;
            }
        }

        final NodeConfig config;
        try {
            // Build the config
            config = node.build();
            if (container.addNode(config, balancer, exchange.getIoThread(), exchange.getConnection().getByteBufferPool())) {
                // Apparently this is hard to do in the C part, so maybe we should just remove this
                if (contexts != null && hosts != null) {
                    for (final String context : contexts) {
                        container.enableContext(context, config.getJvmRoute(), hosts);
                    }
                }
                processOK(exchange);
            } else {
                processError(MCMPErrorCode.NODE_STILL_EXISTS, exchange);
            }
        } catch (Exception e) {
            processError(MCMPErrorCode.CANT_UPDATE_NODE, exchange);
        }
    }
1326813
def getHostOffset(self, host):
        
        info_dict = {}
        output = util.exec_command([ntpdateCmd, '-u', '-q', host])
        for line in output.splitlines():
            mobj = re.match('server.*,\s*stratum\s+(\d),.*'
                            'offset\s+([\d\.-]+),.*delay\s+([\d\.]+)\s*$', 
                            line)
            if mobj:
                info_dict['stratum'] = int(mobj.group(1))
                info_dict['delay'] = float(mobj.group(3))
                info_dict['offset'] = float(mobj.group(2))
                return info_dict
        return info_dict
1270313
def add_host(zone, name, ttl, ip, nameserver='127.0.0.1', replace=True,
             timeout=5, port=53, **kwargs):
    '''
    
    '''
    res = update(zone, name, ttl, 'A', ip, nameserver, timeout, replace, port,
                 **kwargs)
    if res is False:
        return False

    fqdn = '{0}.{1}.'.format(name, zone)
    parts = ip.split('.')[::-1]
    popped = []

    # Iterate over possible reverse zones
    while len(parts) > 1:
        p = parts.pop(0)
        popped.append(p)
        zone = '{0}.{1}'.format('.'.join(parts), 'in-addr.arpa.')
        name = '.'.join(popped)
        ptr = update(zone, name, ttl, 'PTR', fqdn, nameserver, timeout,
                     replace, port, **kwargs)
        if ptr:
            return True
    return res
251235
private PathMatcher.PathMatch<VirtualHost.HostEntry> mapVirtualHost(final HttpServerExchange exchange) {
        final String context = exchange.getRelativePath();
        if(modCluster.isUseAlias()) {
            final String hostName = exchange.getRequestHeaders().getFirst(Headers.HOST);
            if (hostName != null) {
                // Remove the port from the host
                int i = hostName.indexOf(":");
                VirtualHost host;
                if (i > 0) {
                    host = hosts.get(hostName.substring(0, i));
                    if (host == null) {
                        host = hosts.get(hostName);
                    }
                } else {
                    host = hosts.get(hostName);
                }
                if (host == null) {
                    return null;
                }
                PathMatcher.PathMatch<VirtualHost.HostEntry> result = host.match(context);
                if (result.getValue() == null) {
                    return null;
                }
                return result;
            }
        } else {
            for(Map.Entry<String, VirtualHost> host : hosts.entrySet()) {
                PathMatcher.PathMatch<VirtualHost.HostEntry> result = host.getValue().match(context);
                if (result.getValue() != null) {
                    return result;
                }
            }
        }
        return null;
    }
480617
def set_host(self, host):
        
        if host[-1] == '/':
            host = host[:-1]

        self.host = host
        return self
560146
def adjust_ether (self, ip=None, ether=None):
    
# The rules are:
#   1. send to the group mac address address corresponding to the IP.dst
    if ip != None and ip.haslayer(IP) and ether != None and ether.haslayer(Ether):
      iplong = atol(ip.dst)
      ether.dst = "01:00:5e:%02x:%02x:%02x" % ( (iplong>>16)&0x7F, (iplong>>8)&0xFF, (iplong)&0xFF )
      # print "igmpize ip " + ip.dst + " as mac " + ether.dst 
      return True
    else:
      return False
880999
static String normalizeHostname(String hostname) {
        if (needsNormalization(hostname)) {
            hostname = IDN.toASCII(hostname, IDN.ALLOW_UNASSIGNED);
        }
        return hostname.toLowerCase(Locale.US);
    }
1261894
def bind_addr(self, value):
        """"""
        if isinstance(value, tuple) and value[0] in ('', None):
            # Despite the socket module docs, using '' does not
            # allow AI_PASSIVE to work. Passing None instead
            # returns '0.0.0.0' like we want. In other words:
            #     host    AI_PASSIVE     result
            #      ''         Y         192.168.x.y
            #      ''         N         192.168.x.y
            #     None        Y         0.0.0.0
            #     None        N         127.0.0.1
            # But since you can get the same effect with an explicit
            # '0.0.0.0', we deny both the empty string and None as values.
            raise ValueError(
                "Host values of '' or None are not allowed. "
                "Use '0.0.0.0' (IPv4) or '::' (IPv6) instead "
                'to listen on all active interfaces.',
            )
        self._bind_addr = value
517566
function hostnameof (req) {
  var host = req.headers.host

  if (!host) {
    return
  }

  var offset = host[0] === '['
    ? host.indexOf(']') + 1
    : 0
  var index = host.indexOf(':', offset)

  return index !== -1
    ? host.substring(0, index)
    : host
}
1345993
function normalizeConnectArgs(args)
{
	if( typeof args[0]==='object' && args[0]!==null )
		return args[0]
	else if( typeof args[0]==='string' && !(Number(args[0]) >= 0) )
		return {path: args[0]}
	var options= {port: args[0]}
	if( typeof args[1]==='string' )
		options.host= args[1]
	return options
}
811076
static void pingHost(InetSocketAddress address, HttpServerExchange exchange, PingCallback callback, OptionMap options) {

        final XnioIoThread thread = exchange.getIoThread();
        final XnioWorker worker = thread.getWorker();
        final HostPingTask r = new HostPingTask(address, worker, callback, options);
        // Schedule timeout task
        scheduleCancelTask(exchange.getIoThread(), r, 5, TimeUnit.SECONDS);
        exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : thread, r);
    }
1332977
def _expand_host(self, host):
        
        if isinstance(host, basestring):
            return (host, self.default_port)
        return tuple(host)
277384
def init(cnf):
    '''
    
    '''
    CONFIG['host'] = cnf.get('proxy', {}).get('host')
    if not CONFIG['host']:
        raise MinionError(message="Cannot find 'host' parameter in the proxy configuration")

    CONFIG['user'] = cnf.get('proxy', {}).get('user')
    if not CONFIG['user']:
        raise MinionError(message="Cannot find 'user' parameter in the proxy configuration")

    CONFIG['uri'] = "/api/{0}".format(CONFIG['user'])