Parse an HTTP proxy from a String address.
@param proxyAddress The address of the proxy of the form (https?://)HOST:PORT.
@return The URI of the proxy.
@throws IllegalArgumentException If the address is invalid.
427000
@VisibleForTesting
  static URI parseProxyAddress(@Nullable String proxyAddress) {
    if (Strings.isNullOrEmpty(proxyAddress)) {
      return null;
    }
    String uriString = (proxyAddress.contains("//") ? "" : "//") + proxyAddress;
    try {
      URI uri = new URI(uriString);
      String scheme = uri.getScheme();
      String host = uri.getHost();
      int port = uri.getPort();
      checkArgument(
          Strings.isNullOrEmpty(scheme) || scheme.matches("https?"),
          "HTTP proxy address '%s' has invalid scheme '%s'.", proxyAddress, scheme);
      checkArgument(!Strings.isNullOrEmpty(host), "Proxy address '%s' has no host.", proxyAddress);
      checkArgument(port != -1, "Proxy address '%s' has no port.", proxyAddress);
      checkArgument(
          uri.equals(new URI(scheme, null, host, port, null, null, null)),
          "Invalid proxy address '%s'.", proxyAddress);
      return uri;
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException(
          String.format("Invalid proxy address '%s'.", proxyAddress), e);
    }
  }
1155908
def get_ip_address(domain):
    
    if "://" not in domain:
        domain = "http://" + domain

    hostname = urlparse(domain).netloc

    if not hostname:
        raise ValueError("Can't parse hostname!")

    return socket.gethostbyname(hostname)
663875
public String getProxyRemoteAddr(String realIpHeader) {
        String ip = null;
        if (realIpHeader != null && realIpHeader.length() != 0) {
            ip = getHeaderString(realIpHeader);
        }
        if (StringUtils.isBlank(ip)) {
            ip = getHeaderString("X-Real-IP");
            if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
                ip = getHeaderString("X-Forwarded-For");
                if (StringUtils.isNotBlank(ip) && !"unknown".equalsIgnoreCase(ip)) {
                    ip = ip.split(",")[0];
                }
            }
            if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
                ip = getHeaderString("Proxy-Client-IP");
            }
            if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
                ip = getHeaderString("WL-Proxy-Client-IP");
            }
            if (StringUtils.isNotBlank(ip)) {
                ip = ip.toLowerCase();
            }
        }
        return ip;
    }
1063535
def parse_bind_address(address, default=('localhost', 8080)):
    
    if ':' in address:
        host, port = address.split(':', 1)
        port = int(port)
    elif re.match('^\d+$', address):
        host = default[0]
        port = int(address)
    else:
        host = address
        port = default[1]
    return host, port
1098544
public final Object fromAddress(long address) {
		Object[] array = new Object[] { null };
		long baseOffset = THE_UNSAFE.arrayBaseOffset(Object[].class);
		THE_UNSAFE.putLong(array, baseOffset, address);
		return array[0];
	}
638555
public static URI getRequestUri(Response response, AddressFactory addressFactory) throws ParseException {
		final ContactHeader contact = ((ContactHeader) response.getHeader(ContactHeader.NAME));
		return (contact != null) ? (URI) contact.getAddress().getURI().clone() : null;
	}
1350296
private static URL parseURL(String encodedUrl) {
    try {
      return new URL(encodedUrl);
    } catch (MalformedURLException e) {
      throw new IllegalArgumentException(e);
    }
  }
1145808
public static Address from(String hostAndPort) {
    String[] split = hostAndPort.split(":");
    if (split.length != 2) {
      throw new IllegalArgumentException();
    }
    String host = split[0];
    int port = Integer.parseInt(split[1]);
    return new Address(host, port);
  }
1318588
public boolean shouldProxy(SocketAddress address) {
		SocketAddress addr = address;
		if (address instanceof TcpUtils.SocketAddressSupplier) {
			addr = ((TcpUtils.SocketAddressSupplier) address).get();
		}
		return addr instanceof InetSocketAddress && shouldProxy(((InetSocketAddress) addr).getHostString());
	}
588930
private String parseAddress(String address) {
        try {
            StringBuilder buf = new StringBuilder();
            InternetAddress[] netAddrs = InternetAddress.parseHeader(address, false);
            for (InternetAddress netAddr : netAddrs) {
                if (buf.length() > 0) {
                    buf.append(SP);
                }

                buf.append(LB);

                String personal = netAddr.getPersonal();
                if (personal != null && (personal.length() != 0)) {
                    buf.append(Q).append(personal).append(Q);
                } else {
                    buf.append(NIL);
                }
                buf.append(SP);
                buf.append(NIL); // should add route-addr
                buf.append(SP);
                try {
                    // Remove quotes to avoid double quoting
                    MailAddress mailAddr = new MailAddress(netAddr.getAddress().replaceAll("\"", "\\\\\""));
                    buf.append(Q).append(mailAddr.getUser()).append(Q);
                    buf.append(SP);
                    buf.append(Q).append(mailAddr.getHost()).append(Q);
                } catch (Exception pe) {
                    buf.append(NIL + SP + NIL);
                }
                buf.append(RB);
            }

            return buf.toString();
        } catch (AddressException e) {
            throw new RuntimeException("Failed to parse address: " + address, e);
        }
    }
957291
public static String extractIPAddress(final HttpServletRequest request) {

        String ip = request.getHeader("x-forwarded-for");
        if (isIPAdressValid(ip)) {
            return ip;
        }
        ip = request.getHeader("Proxy-Client-IP");
        if (isIPAdressValid(ip)) {
            return ip;
        }
        ip = request.getHeader("WL-Proxy-Client-IP");
        if (isIPAdressValid(ip)) {
            return ip;
        }
        return request.getRemoteAddr();
    }
1299928
@VisibleForTesting
  static String makeTargetStringForDirectAddress(SocketAddress address) {
    try {
      return new URI(DIRECT_ADDRESS_SCHEME, "", "/" + address, null).toString();
    } catch (URISyntaxException e) {
      // It should not happen.
      throw new RuntimeException(e);
    }
  }
614378
public static Proxy forPropertiesOpt(String prefix) {
        String host;
        String port;
        Proxy result;

        host = System.getProperty(prefix + ".proxyHost");
        if (host == null) {
            return null;
        }
        port = System.getProperty(prefix + ".proxyPort");
        if (port == null) {
            throw new IllegalStateException("missing proxy port for host " + host);
        }
        result = new Proxy(host, Integer.parseInt(port));
        result.excludes.addAll(NON_PROXY_SEP.split(System.getProperty(prefix + ".nonProxyHosts", "")));
        return result;
    }
113875
private Proxy getProxyForUrl(String requestUrl) {
    List<Proxy> proxies = props.getProxies();
    if (proxies == null || proxies.isEmpty()) {
      return null;
    }
    final URI uri = URI.create(requestUrl);
    for (Proxy proxy : proxies) {
      if (!proxy.isNonProxyHost(uri.getHost())) {
        return proxy;
      }
    }
    return null;
  }
289818
public static dnsaddrec get(nitro_service service, String hostname) throws Exception{
		dnsaddrec obj = new dnsaddrec();
		obj.set_hostname(hostname);
		dnsaddrec response = (dnsaddrec) obj.get_resource(service);
		return response;
	}
1197554
private void setProxy(String proxyStr) {
    String[] strs = proxyStr.split(":", 2);
    if (strs.length != 2)
      throw new RuntimeException("Bad SOCKS proxy parameter: " + proxyStr);
    String host = strs[0];
    int port = Integer.parseInt(strs[1]);
    this.proxy =
        new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved(host,
            port));
  }
1146788
public static String getProxy() throws InvalidProxyException {
        String proxy = getProgramProperty(PROXY);
        if (proxy == null) {
            throw new InvalidProxyException(PROXY_ISNT_SET);
        }
        String[] proxyParts = proxy.split(":");
        if (proxyParts.length != 2) {
            throw new InvalidProxyException("Proxy '" + proxy + "' isn't valid. Must contain address and port, without protocol");
        }
        try {
            Integer.parseInt(proxyParts[1]);
        } catch (NumberFormatException e) {
            throw new InvalidProxyException("Proxy '" + proxy + "' isn't valid. Must contain address and port, without protocol. Invalid port provided. " + e);
        }
        return proxy;
    }