Java 类java.net.Proxy.Type 实例源码

项目:letv    文件:p.java   
private static HttpURLConnection a(Context context, String str) {
    try {
        URL url = new URL(str);
        if (context.getPackageManager().checkPermission(z[43], context.getPackageName()) == 0) {
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService(z[44])).getActiveNetworkInfo();
            if (!(activeNetworkInfo == null || activeNetworkInfo.getType() == 1)) {
                String extraInfo = activeNetworkInfo.getExtraInfo();
                if (extraInfo != null && (extraInfo.equals(z[40]) || extraInfo.equals(z[41]) || extraInfo.equals(z[42]))) {
                    return (HttpURLConnection) url.openConnection(new Proxy(Type.HTTP, new InetSocketAddress(z[45], 80)));
                }
            }
        }
        return (HttpURLConnection) url.openConnection();
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
    } catch (IOException e2) {
        e2.printStackTrace();
        return null;
    }
}
项目:Wurst-MC-1.12    文件:JGoogleAnalyticsTracker.java   
/**
 * Define the proxy to use for all GA tracking requests.
 * <p>
 * Call this static method early (before creating any tracking requests).
 *
 * @param proxyAddr
 *            "addr:port" of the proxy to use; may also be given as URL
 *            ("http://addr:port/").
 */
public static void setProxy(String proxyAddr)
{
    if(proxyAddr != null)
    {
        Scanner s = new Scanner(proxyAddr);

        // Split into "proxyAddr:proxyPort".
        proxyAddr = null;
        int proxyPort = 8080;
        try
        {
            s.findInLine("(http://|)([^:/]+)(:|)([0-9]*)(/|)");
            MatchResult m = s.match();

            if(m.groupCount() >= 2)
                proxyAddr = m.group(2);

            if(m.groupCount() >= 4 && !(m.group(4).length() == 0))
                proxyPort = Integer.parseInt(m.group(4));
        }finally
        {
            s.close();
        }

        if(proxyAddr != null)
        {
            SocketAddress sa = new InetSocketAddress(proxyAddr, proxyPort);
            setProxy(new Proxy(Type.HTTP, sa));
        }
    }
}
项目:google-cloud-eclipse    文件:ProxyFactory.java   
@VisibleForTesting
public Proxy createProxy(URI uri) {
  Preconditions.checkNotNull(uri, "uri is null");
  Preconditions.checkArgument(!"http".equals(uri.getScheme()), "http is not a supported schema");

  IProxyService proxyServiceCopy = proxyService;
  if (proxyServiceCopy == null) {
    return Proxy.NO_PROXY;
  }

  IProxyData[] proxyDataForUri = proxyServiceCopy.select(uri);
  for (final IProxyData iProxyData : proxyDataForUri) {
    switch (iProxyData.getType()) {
      case IProxyData.HTTPS_PROXY_TYPE:
        return new Proxy(Type.HTTP, new InetSocketAddress(iProxyData.getHost(),
                                                          iProxyData.getPort()));
      case IProxyData.SOCKS_PROXY_TYPE:
        return new Proxy(Type.SOCKS, new InetSocketAddress(iProxyData.getHost(),
                                                           iProxyData.getPort()));
      default:
        logger.warning("Unsupported proxy type: " + iProxyData.getType());
        break;
    }
  }
  return Proxy.NO_PROXY;
}
项目:LambdaAttack    文件:LoadProxiesListener.java   
@Override
public void actionPerformed(ActionEvent actionEvent) {
    int returnVal = fileChooser.showOpenDialog(frame);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File proxyFile = fileChooser.getSelectedFile();
        LambdaAttack.getLogger().log(Level.INFO, "Opening: {0}.", proxyFile.getName());

        botManager.getThreadPool().submit(() -> {
            try {
                List<Proxy> proxies = Files.lines(proxyFile.toPath()).distinct().map((line) -> {
                    String host = line.split(":")[0];
                    int port = Integer.parseInt(line.split(":")[1]);

                    InetSocketAddress address = new InetSocketAddress(host, port);
                    return new Proxy(Type.SOCKS, address);
                }).collect(Collectors.toList());

                LambdaAttack.getLogger().log(Level.INFO, "Loaded {0} proxies", proxies.size());

                botManager.setProxies(proxies);
            } catch (Exception ex) {
                LambdaAttack.getLogger().log(Level.SEVERE, null, ex);
            }
        });
    }
}
项目:EvenWurse    文件:JGoogleAnalyticsTracker.java   
/**
 * Define the proxy to use for all GA tracking requests.
 * <p>
 * Call this static method early (before creating any tracking requests).
 *
 * @param proxyAddr
 *            "addr:port" of the proxy to use; may also be given as URL
 *            ("http://addr:port/").
 */
public static void setProxy(String proxyAddr) {
    if (proxyAddr != null) {

        String oldProxyAddr = proxyAddr;
        // Split into "proxyAddr:proxyPort".
        proxyAddr = null;
        int proxyPort = 8080;
        try (Scanner s = new Scanner(oldProxyAddr)) {
            s.findInLine("(http://|)([^:/]+)(:|)([0-9]*)(/|)");
            MatchResult m = s.match();

            if (m.groupCount() >= 2) proxyAddr = m.group(2);

            if (m.groupCount() >= 4 && !(m.group(4).length() == 0)) proxyPort = Integer.parseInt(m.group(4));
        }

        if (proxyAddr != null) {
            SocketAddress sa = new InetSocketAddress(proxyAddr, proxyPort);
            setProxy(new Proxy(Type.HTTP, sa));
        }
    }
}
项目:FMTech    文件:RouteSelector.java   
public final void connectFailed(Connection paramConnection, IOException paramIOException)
{
  if (Internal.instance.recycleCount(paramConnection) > 0) {}
  for (;;)
  {
    return;
    Route localRoute1 = paramConnection.route;
    if ((localRoute1.proxy.type() != Proxy.Type.DIRECT) && (this.address.proxySelector != null)) {
      this.address.proxySelector.connectFailed(this.uri, localRoute1.proxy.address(), paramIOException);
    }
    this.routeDatabase.failed(localRoute1);
    if ((!(paramIOException instanceof SSLHandshakeException)) && (!(paramIOException instanceof SSLProtocolException))) {
      while (this.nextSpecIndex < this.connectionSpecs.size())
      {
        List localList = this.connectionSpecs;
        int i = this.nextSpecIndex;
        this.nextSpecIndex = (i + 1);
        ConnectionSpec localConnectionSpec = (ConnectionSpec)localList.get(i);
        boolean bool = shouldSendTlsFallbackIndicator(localConnectionSpec);
        Route localRoute2 = new Route(this.address, this.lastProxy, this.lastInetSocketAddress, localConnectionSpec, bool);
        this.routeDatabase.failed(localRoute2);
      }
    }
  }
}
项目:Tank    文件:PacProxySelector.java   
protected void convert(String pacResult, List<Proxy> result) {
    Matcher m = PAC_RESULT_PATTERN.matcher(pacResult);
    while (m.find()) {
        String scriptProxyType = m.group(1);
        if ("DIRECT".equals(scriptProxyType)) {
            result.add(Proxy.NO_PROXY);
        } else {
            Type proxyType;
            if ("PROXY".equals(scriptProxyType)) {
                proxyType = Type.HTTP;
            } else if ("SOCKS".equals(scriptProxyType)) {
                proxyType = Type.SOCKS;
            } else {
                // Should never happen, already filtered by Pattern.
                throw new RuntimeException("Unrecognized proxy type.");
            }
            result.add(new Proxy(proxyType, new InetSocketAddress(m
                    .group(2), Integer.parseInt(m.group(3)))));
        }
    }
}
项目:icedtea-web    文件:BrowserAwareProxySelectorTest.java   
@Test
public void testBrowserManualSameProxy() throws URISyntaxException {
    browserPrefs.put("network.proxy.type", "1" /* = manual */);
    browserPrefs.put("network.proxy.share_proxy_settings", "true");
    browserPrefs.put("network.proxy.http", PROXY_HOST);
    browserPrefs.put("network.proxy.http_port", String.valueOf(PROXY_PORT));

    List<Proxy> result;

    result = getProxy(config, browserPrefs, new URI("https://example.org"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, PROXY_ADDRESS), result.get(0));

    result = getProxy(config, browserPrefs, new URI("socket://example.org"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.SOCKS, PROXY_ADDRESS), result.get(0));

}
项目:icedtea-web    文件:JNLPProxySelectorTest.java   
@Test
public void testManualHttpProxy() throws URISyntaxException {
    String HTTP_HOST = "example.org";
    int HTTP_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTP_HOST, HTTP_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTP_PORT, String.valueOf(HTTP_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("http://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, new InetSocketAddress(HTTP_HOST, HTTP_PORT)), result.get(0));
}
项目:icedtea-web    文件:JNLPProxySelectorTest.java   
@Test
public void testManualHttpsProxy() throws URISyntaxException {
    String HTTPS_HOST = "example.org";
    int HTTPS_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTPS_HOST, HTTPS_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTPS_PORT, String.valueOf(HTTPS_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("https://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, new InetSocketAddress(HTTPS_HOST, HTTPS_PORT)), result.get(0));
}
项目:icedtea-web    文件:JNLPProxySelectorTest.java   
@Test
public void testManualFtpProxy() throws URISyntaxException {
    String FTP_HOST = "example.org";
    int FTP_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_FTP_HOST, FTP_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_FTP_PORT, String.valueOf(FTP_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("ftp://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, new InetSocketAddress(FTP_HOST, FTP_PORT)), result.get(0));
}
项目:icedtea-web    文件:JNLPProxySelectorTest.java   
@Test
public void testManualSocksProxy() throws URISyntaxException {
    String SOCKS_HOST = "example.org";
    int SOCKS_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_HOST, SOCKS_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_PORT, String.valueOf(SOCKS_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("socket://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.SOCKS, new InetSocketAddress(SOCKS_HOST, SOCKS_PORT)), result.get(0));
}
项目:icedtea-web    文件:JNLPProxySelectorTest.java   
@Test
public void testHttpFallsBackToManualSocksProxy() throws URISyntaxException {
    String SOCKS_HOST = "example.org";
    int SOCKS_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_HOST, SOCKS_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_PORT, String.valueOf(SOCKS_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("http://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.SOCKS, new InetSocketAddress(SOCKS_HOST, SOCKS_PORT)), result.get(0));
}
项目:icedtea-web    文件:JNLPProxySelectorTest.java   
@Test
public void testManualSameProxy() throws URISyntaxException {
    final String HTTP_HOST = "example.org";
    final int HTTP_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTP_HOST, HTTP_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTP_PORT, String.valueOf(HTTP_PORT));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SAME, String.valueOf(true));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result;

    result = selector.select(new URI("http://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, new InetSocketAddress(HTTP_HOST, HTTP_PORT)), result.get(0));
}
项目:cppcheclipse    文件:HttpClientService.java   
private Proxy getProxyFromProxyData(IProxyData proxyData) throws UnknownHostException {

    Type proxyType;
    if (IProxyData.HTTP_PROXY_TYPE.equals(proxyData.getType())) {
        proxyType = Type.HTTP;
    } else if (IProxyData.SOCKS_PROXY_TYPE.equals(proxyData.getType())) {
        proxyType = Type.SOCKS;
    } else if (IProxyData.HTTPS_PROXY_TYPE.equals(proxyData.getType())) {
        proxyType = Type.HTTP;
    } else {
        throw new IllegalArgumentException("Invalid proxy type " + proxyData.getType());
    }

    InetSocketAddress sockAddr = new InetSocketAddress(InetAddress.getByName(proxyData.getHost()), proxyData.getPort());
    Proxy proxy = new Proxy(proxyType, sockAddr);
    if (!Strings.isNullOrEmpty(proxyData.getUserId())) {
        Authenticator.setDefault(new ProxyAuthenticator(proxyData.getUserId(), proxyData.getPassword()));  
    }
    return proxy;
}
项目:QuizUpWinner    文件:·¥Ω.java   
private Proxy ˋ()
{
  if (this.ˈ != null)
  {
    this.ʼ = false;
    return this.ˈ;
  }
  if (this.ˉ != null)
    while (this.ˉ.hasNext())
    {
      Proxy localProxy = (Proxy)this.ˉ.next();
      if (localProxy.type() != Proxy.Type.DIRECT)
        return localProxy;
    }
  this.ʼ = false;
  return Proxy.NO_PROXY;
}
项目:QuizUpWinner    文件:Àä$if.java   
public static String ˊ( paramᔨ, Proxy.Type paramType, int paramInt)
{
  StringBuilder localStringBuilder = new StringBuilder();
  localStringBuilder.append(paramᔨ.ˎ());
  localStringBuilder.append(" ");
  int i;
  if ((!paramᔨ.()) && (paramType == Proxy.Type.HTTP))
    i = 1;
  else
    i = 0;
  if (i != 0)
    localStringBuilder.append(paramᔨ.ˊ());
  else
    localStringBuilder.append(ˊ(paramᔨ.ˊ()));
  localStringBuilder.append(" ");
  String str;
  if (paramInt == 1)
    str = "HTTP/1.1";
  else
    str = "HTTP/1.0";
  localStringBuilder.append(str);
  return localStringBuilder.toString();
}
项目:weixinmp4java    文件:AbstractWeixinmpController.java   
/**
 * 初始化HTTP代理服务器
 */
private void initHttpProxy() {
    // 初始化代理服务器
    if (httpProxyHost != null && httpProxyPort != null) {
        SocketAddress sa = new InetSocketAddress(httpProxyHost, httpProxyPort);
        proxy = new Proxy(Type.HTTP, sa);
        // 初始化代理服务器的用户验证
        if (httpProxyUsername != null && httpProxyPassword != null) {
            Authenticator.setDefault(new Authenticator() {

                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(httpProxyUsername, httpProxyPassword.toCharArray());
                }
            });
        }

    }
}
项目:weixinmp4java    文件:AbstractWeixinmpController.java   
/**
 * 初始化HTTP代理服务器
 */
private void initHttpProxy() {
    // 初始化代理服务器
    if (httpProxyHost != null && httpProxyPort != null) {
        SocketAddress sa = new InetSocketAddress(httpProxyHost, httpProxyPort);
        proxy = new Proxy(Type.HTTP, sa);
        // 初始化代理服务器的用户验证
        if (httpProxyUsername != null && httpProxyPassword != null) {
            Authenticator.setDefault(new Authenticator() {

                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(httpProxyUsername, httpProxyPassword.toCharArray());
                }
            });
        }

    }
}
项目:cn1    文件:URLTest.java   
/**
 * @throws IOException
 * @tests java.net.URL#openConnection(Proxy)
 */
public void test_openConnection_proxy_SelectorCalled() throws IOException {
    URL httpUrl = new URL("http://"
            + Support_Configuration.ProxyServerTestHost
            + "/cgi-bin/test.pl");

    try {
        httpUrl.openConnection(null);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // expected
    }

    URLConnection uc = httpUrl.openConnection(new Proxy(Type.SOCKS,
            new InetSocketAddress(InetAddress.getLocalHost(), 80)));
    assertEquals(uc.getURL(), httpUrl);
}
项目:spork-streaming    文件:SSHSocketImplFactory.java   
public Socket createSocket(String host, int port) throws IOException,
        UnknownHostException {
    String socksHost = System.getProperty("socksProxyHost");
    Socket s;
    InetSocketAddress addr = new InetSocketAddress(host, port);
    if (socksHost != null) {
        Proxy proxy = new Proxy(Type.SOCKS, new InetSocketAddress(
                socksHost, 1080));
        s = new Socket(proxy);
        s.connect(addr);
    } else {
        log.error(addr);
        SocketChannel sc = SocketChannel.open(addr);
        s = sc.socket();
    }
    s.setTcpNoDelay(true);
    return s;
}
项目:Cauldron    文件:Main.java   
public java.lang.reflect.Type[] getActualTypeArguments()
{
    return new java.lang.reflect.Type[] {String.class, new ParameterizedType()
    {
        private static final String __OBFID = "CL_00001836";
        public java.lang.reflect.Type[] getActualTypeArguments()
        {
            return new java.lang.reflect.Type[] {String.class};
        }
        public java.lang.reflect.Type getRawType()
        {
            return Collection.class;
        }
        public java.lang.reflect.Type getOwnerType()
        {
            return null;
        }
    }
                                        };
}
项目:Cauldron    文件:Main.java   
public java.lang.reflect.Type[] getActualTypeArguments()
{
    return new java.lang.reflect.Type[] {String.class, new ParameterizedType()
    {
        private static final String __OBFID = "CL_00001836";
        public java.lang.reflect.Type[] getActualTypeArguments()
        {
            return new java.lang.reflect.Type[] {String.class};
        }
        public java.lang.reflect.Type getRawType()
        {
            return Collection.class;
        }
        public java.lang.reflect.Type getOwnerType()
        {
            return null;
        }
    }
                                        };
}
项目:freeVM    文件:URLTest.java   
/**
 * @throws IOException
 * @tests java.net.URL#openConnection(Proxy)
 */
public void test_openConnection_proxy_SelectorCalled() throws IOException {
    URL httpUrl = new URL("http://"
            + Support_Configuration.ProxyServerTestHost
            + "/cgi-bin/test.pl");

    try {
        httpUrl.openConnection(null);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // expected
    }

    URLConnection uc = httpUrl.openConnection(new Proxy(Type.SOCKS,
            new InetSocketAddress(InetAddress.getLocalHost(), 80)));
    assertEquals(uc.getURL(), httpUrl);
}
项目:PonIC    文件:SSHSocketImplFactory.java   
public Socket createSocket(String host, int port) throws IOException,
        UnknownHostException {
    String socksHost = System.getProperty("socksProxyHost");
    Socket s;
    InetSocketAddress addr = new InetSocketAddress(host, port);
    if (socksHost != null) {
        Proxy proxy = new Proxy(Type.SOCKS, new InetSocketAddress(
                socksHost, 1080));
        s = new Socket(proxy);
        s.connect(addr);
    } else {
        log.error(addr);
        SocketChannel sc = SocketChannel.open(addr);
        s = sc.socket();
    }
    s.setTcpNoDelay(true);
    return s;
}
项目:sedge    文件:SSHSocketImplFactory.java   
public Socket createSocket(String host, int port) throws IOException,
        UnknownHostException {
    String socksHost = System.getProperty("socksProxyHost");
    Socket s;
    InetSocketAddress addr = new InetSocketAddress(host, port);
    if (socksHost != null) {
        Proxy proxy = new Proxy(Type.SOCKS, new InetSocketAddress(
                socksHost, 1080));
        s = new Socket(proxy);
        s.connect(addr);
    } else {
        log.error(addr);
        SocketChannel sc = SocketChannel.open(addr);
        s = sc.socket();
    }
    s.setTcpNoDelay(true);
    return s;
}
项目:geocoder-microservices    文件:RestTemplateConfig.java   
@Bean
public RestTemplate restTemplate() {
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();

    Proxy proxy= new Proxy(Type.HTTP, new InetSocketAddress("vip-px.main.aviva.eu.corp", 8080));
    requestFactory.setProxy(proxy);
    return new RestTemplate(requestFactory);
   // return new RestTemplate();
}
项目:neoscada    文件:Processor.java   
private HttpURLConnection openConnection ( final URL url ) throws IOException
{
    final String host = this.properties.getProperty ( "local.proxy.host" );
    final String port = this.properties.getProperty ( "local.proxy.port" );

    if ( host != null && port != null && !host.isEmpty () && !port.isEmpty () )
    {
        final Proxy proxy = new Proxy ( Type.HTTP, new InetSocketAddress ( host, Integer.parseInt ( port ) ) );
        return (HttpURLConnection)url.openConnection ( proxy );
    }
    else
    {
        return (HttpURLConnection)url.openConnection ();
    }
}
项目:BaseClient    文件:ThreadDownloadImageData.java   
private boolean shouldPipeline()
{
    if (!this.pipeline)
    {
        return false;
    }
    else
    {
        Proxy proxy = Minecraft.getMinecraft().getProxy();
        return proxy.type() != Type.DIRECT && proxy.type() != Type.SOCKS ? false : this.imageUrl.startsWith("http://");
    }
}
项目:boohee_v5.6    文件:RouteSelector.java   
public void connectFailed(Route failedRoute, IOException failure) {
    if (!(failedRoute.getProxy().type() == Type.DIRECT || this.address.getProxySelector() ==
            null)) {
        this.address.getProxySelector().connectFailed(this.address.url().uri(), failedRoute
                .getProxy().address(), failure);
    }
    this.routeDatabase.failed(failedRoute);
}
项目:boohee_v5.6    文件:RouteSelector.java   
private void resetNextInetSocketAddress(Proxy proxy) throws IOException {
    String socketHost;
    int socketPort;
    this.inetSocketAddresses = new ArrayList();
    if (proxy.type() == Type.DIRECT || proxy.type() == Type.SOCKS) {
        socketHost = this.address.getUriHost();
        socketPort = this.address.getUriPort();
    } else {
        SocketAddress proxyAddress = proxy.address();
        if (proxyAddress instanceof InetSocketAddress) {
            InetSocketAddress proxySocketAddress = (InetSocketAddress) proxyAddress;
            socketHost = getHostString(proxySocketAddress);
            socketPort = proxySocketAddress.getPort();
        } else {
            throw new IllegalArgumentException("Proxy.address() is not an InetSocketAddress: " +
                    "" + proxyAddress.getClass());
        }
    }
    if (socketPort < 1 || socketPort > 65535) {
        throw new SocketException("No route to " + socketHost + ":" + socketPort + "; port is" +
                " out of range");
    }
    if (proxy.type() == Type.SOCKS) {
        this.inetSocketAddresses.add(InetSocketAddress.createUnresolved(socketHost,
                socketPort));
    } else {
        List<InetAddress> addresses = this.address.getDns().lookup(socketHost);
        int size = addresses.size();
        for (int i = 0; i < size; i++) {
            this.inetSocketAddresses.add(new InetSocketAddress((InetAddress) addresses.get(i)
                    , socketPort));
        }
    }
    this.nextInetSocketAddressIndex = 0;
}
项目:boohee_v5.6    文件:RequestLine.java   
static String get(Request request, Type proxyType) {
    StringBuilder result = new StringBuilder();
    result.append(request.method());
    result.append(' ');
    if (includeAuthorityInRequestLine(request, proxyType)) {
        result.append(request.httpUrl());
    } else {
        result.append(requestPath(request.httpUrl()));
    }
    result.append(" HTTP/1.1");
    return result.toString();
}
项目:boohee_v5.6    文件:HttpURLConnectionImpl.java   
public final boolean usingProxy() {
    Proxy proxy;
    if (this.route != null) {
        proxy = this.route.getProxy();
    } else {
        proxy = this.client.getProxy();
    }
    return (proxy == null || proxy.type() == Type.DIRECT) ? false : true;
}
项目:boohee_v5.6    文件:d.java   
public static HttpURLConnection b(Context context, URL url) {
    if (!"http".equals(url.getProtocol())) {
        return (HttpURLConnection) url.openConnection();
    }
    if (c(context)) {
        return (HttpURLConnection) url.openConnection(new Proxy(Type.HTTP, new
                InetSocketAddress("10.0.0.200", 80)));
    }
    if (!b(context)) {
        return (HttpURLConnection) url.openConnection();
    }
    HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(a(url)).openConnection();
    httpURLConnection.addRequestProperty(Network.CMWAP_HEADER_HOST_KEY, url.getHost());
    return httpURLConnection;
}
项目:boohee_v5.6    文件:Network.java   
private static HttpURLConnection getHttpUrlConnection(Context context, URL url) throws
        IOException {
    if (isCtwap(context)) {
        return (HttpURLConnection) url.openConnection(new Proxy(Type.HTTP, new
                InetSocketAddress("10.0.0.200", 80)));
    }
    if (!isCmwap(context)) {
        return (HttpURLConnection) url.openConnection();
    }
    HttpURLConnection conn = (HttpURLConnection) new URL(getCMWapUrl(url)).openConnection();
    conn.addRequestProperty(CMWAP_HEADER_HOST_KEY, url.getHost());
    return conn;
}
项目:Backmemed    文件:ThreadDownloadImageData.java   
private boolean shouldPipeline()
{
    if (!this.pipeline)
    {
        return false;
    }
    else
    {
        Proxy proxy = Minecraft.getMinecraft().getProxy();
        return proxy.type() != Type.DIRECT && proxy.type() != Type.SOCKS ? false : this.imageUrl.startsWith("http://");
    }
}
项目:Asynchronous-Android-Programming    文件:HTTPProxy.java   
Type toType(){
    switch (this){
        case SOCKS: return Type.SOCKS;
        case HTTP: return Type.HTTP;
    }
    return  Type.DIRECT;
}
项目:proxy-vole    文件:PacProxySelectorTest.java   
/*************************************************************************
 * Test method
 * 
 * @throws ProxyException
 *             on proxy detection error.
 * @throws MalformedURLException
 *             on URL erros
 ************************************************************************/
@Test
public void testScriptMuliProxy() throws ProxyException, MalformedURLException {
    PacProxySelector pacProxySelector = new PacProxySelector(new UrlPacScriptSource(toUrl("testMultiProxy.pac")));
    List<Proxy> result = pacProxySelector.select(TestUtil.HTTP_TEST_URI);
    assertEquals(4, result.size());
       assertEquals(new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("my-proxy.com", 80)), result.get(0));
       assertEquals(new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("my-proxy2.com", 8080)), result.get(1));
       assertEquals(new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("my-proxy3.com", 8080)), result.get(2));
       assertEquals(new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("my-proxy4.com", 80)), result.get(3));
}
项目:proxy-vole    文件:PacProxySelectorTest.java   
/*************************************************************************
 * Test method for the override local IP feature.
 * 
 * @throws ProxyException
 *             on proxy detection error.
 * @throws MalformedURLException
 *             on URL erros
 ************************************************************************/
@Test
public void testLocalIPOverride() throws ProxyException, MalformedURLException {
    System.setProperty(PacScriptMethods.OVERRIDE_LOCAL_IP, "123.123.123.123");
    try {
        PacProxySelector pacProxySelector = new PacProxySelector(new UrlPacScriptSource(toUrl("testLocalIP.pac")));
        List<Proxy> result = pacProxySelector.select(TestUtil.HTTP_TEST_URI);
        assertEquals(result.get(0),
                new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("123.123.123.123", 8080)));
    } finally {
        System.setProperty(PacScriptMethods.OVERRIDE_LOCAL_IP, "");
    }

}
项目:java-bambou    文件:RestClientTemplate.java   
public void setHttpProxy(String host, int port) {
    if (host != null && !host.isEmpty()) {
        // Debug
        logger.debug("Using HTTP proxy for REST connection: " + host + ":" + port);

        // Set proxy
        SimpleClientHttpRequestFactory requestFactory = (SimpleClientHttpRequestFactory) getRequestFactory();
        Proxy proxy = new Proxy(Type.HTTP, new InetSocketAddress(host, port));
        requestFactory.setProxy(proxy);
    }
}