static InetSocketAddress getProxyAddress(Proxy proxy) { String httpProxy = proxy.getHttpProxy(); String host = httpProxy.replaceFirst("(.*):.*", "$1"); String port = httpProxy.replaceFirst(".*:(.*)", "$1"); return new InetSocketAddress(host, parseInt(port)); }
switch (proxy.getProxyType()) { case MANUAL: if (proxy.getHttpProxy() != null && !proxy.getHttpProxy().isEmpty()) { //< HTTP proxy argsBuilder.add("--proxy-type=http"); argsBuilder.add(String.format("--proxy=%s", proxy.getHttpProxy())); } else if (proxy.getSocksProxy() != null && !proxy.getSocksProxy().isEmpty()) { //< SOCKS5 proxy argsBuilder.add("--proxy-type=socks5");
default List<String> applyPhantomJSProxySettings(List<String> cliArguments, Proxy proxySettings) { if (null == proxySettings) { cliArguments.add("--proxy-type=none"); } else { cliArguments.add("--proxy-type=http"); cliArguments.add("--proxy=" + proxySettings.getHttpProxy()); } return cliArguments; } }
Settings build(Capabilities capabilities) { Map properties = new HashMap(capabilities.asMap()); Proxy proxy = Proxy.extractFrom(capabilities); if (proxy != null) { String proxyConfigString = proxy.getHttpProxy(); if (proxyConfigString != null) { Pattern pattern = Pattern.compile("(?:http(?:s)?:\\/\\/)?(?:([^:@]*):([^:@]*)@)?([^:@]*)(?::(\\d+))?"); Matcher matcher = pattern.matcher(proxyConfigString); if (matcher.matches()) { properties.put(PropertyName.PROXY_TYPE.propertyName, ProxyConfig.Type.HTTP); properties.put(PropertyName.PROXY_USERNAME.propertyName, matcher.group(1)); properties.put(PropertyName.PROXY_PASSWORD.propertyName, matcher.group(2)); properties.put(PropertyName.PROXY_HOST.propertyName, matcher.group(3)); properties.put(PropertyName.PROXY_PORT.propertyName, matcher.group(4)); } } } for (Map.Entry entry : System.getProperties().entrySet()) { properties.put(entry.getKey(), entry.getValue()); } return new Settings(this, properties); } }
builder.append(", ftp=").append(p); p = getHttpProxy(); if (p != null) { builder.append(", http=").append(p);
String httpProxy = proxy.getHttpProxy(); if (httpProxy != null && !httpProxy.equals("")) { String host = httpProxy;
switch (proxy.getProxyType()) { case MANUAL: if (proxy.getHttpProxy() != null && !proxy.getHttpProxy().isEmpty()) { //< HTTP proxy argsBuilder.add("--proxy-type=http"); argsBuilder.add(String.format("--proxy=%s", proxy.getHttpProxy())); } else if (proxy.getSocksProxy() != null && !proxy.getSocksProxy().isEmpty()) { //< SOCKS5 proxy argsBuilder.add("--proxy-type=socks5");
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Proxy proxy = (Proxy) o; return isAutodetect() == proxy.isAutodetect() && getProxyType() == proxy.getProxyType() && Objects.equals(getFtpProxy(), proxy.getFtpProxy()) && Objects.equals(getHttpProxy(), proxy.getHttpProxy()) && Objects.equals(getNoProxy(), proxy.getNoProxy()) && Objects.equals(getSslProxy(), proxy.getSslProxy()) && Objects.equals(getSocksProxy(), proxy.getSocksProxy()) && Objects.equals(getSocksVersion(), proxy.getSocksVersion()) && Objects.equals(getSocksUsername(), proxy.getSocksUsername()) && Objects.equals(getSocksPassword(), proxy.getSocksPassword()) && Objects.equals(getProxyAutoconfigUrl(), proxy.getProxyAutoconfigUrl()); }
@Override public int hashCode() { return Objects.hash( getProxyType(), isAutodetect(), getFtpProxy(), getHttpProxy(), getNoProxy(), getSslProxy(), getSocksProxy(), getSocksVersion(), getSocksUsername(), getSocksPassword(), getProxyAutoconfigUrl()); } }
if (proxy.getHttpProxy() != null) { setHttpProxy(proxy.getHttpProxy());