Parse an instance of {@link Proxy}, merge and apply its configuration to the current Opera
instance.
326248
public void parse(Proxy proxy) {
    if (proxy.getProxyType() == Proxy.ProxyType.UNSPECIFIED) {
      return;
    }

    reset();

    switch (proxy.getProxyType()) {
      case DIRECT:
        if (!product.is(MOBILE)) {
          setEnabled(false);
        }
        setUsePAC(false);
        break;

      case MANUAL:
        if (!product.is(MOBILE)) {
          setEnabled(true);
        }
        setUsePAC(false);

        // TODO(andreastt): HTTPS proxy
        // TODO(andreastt): SOCKS proxy

        if (proxy.getHttpProxy() != null) {
          setHttpProxy(proxy.getHttpProxy());
        }
        if (proxy.getFtpProxy() != null) {
          setFtpProxy(proxy.getFtpProxy());
        }

        break;

      case PAC:
        if (!product.is(MOBILE)) {
          setEnabled(true);
        }
        setUsePAC(true);

        if (proxy.getProxyAutoconfigUrl() != null) {
          setAutoconfigUrl(proxy.getProxyAutoconfigUrl());
        }

        break;

      default:
        logger.warning("Unsupported proxy type: " + proxy.getProxyType());
    }
  }
519705
private static KunderaProxy getProxyInstance(Class factory, CglibLazyInitializer instance)
    {
        KunderaProxy proxy;
        try
        {
            Enhancer.registerCallbacks(factory, new Callback[] { instance, null });
            proxy = (KunderaProxy) factory.newInstance();
        }
        catch (IllegalAccessException e)
        {
            throw new LazyInitializationException(e);
        }
        catch (InstantiationException e)
        {
            throw new LazyInitializationException(e);
        }
        finally
        {
            Enhancer.registerCallbacks(factory, null);
        }
        return proxy;
    }
1149951
public void setProxy(URI proxy) {
        this.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxy.getHost(), proxy.getPort(), proxy.getScheme()));
    }
1351077
@SuppressWarnings("unchecked")
    public <T> T parseInterface(final Class<T> serviceInterface, FoxHttpClient foxHttpClient) throws FoxHttpException {

        try {
            Method[] methods = serviceInterface.getDeclaredMethods();

            for (Method method : methods) {
                FoxHttpMethodParser foxHttpMethodParser = new FoxHttpMethodParser();
                foxHttpMethodParser.parseMethod(method, foxHttpClient);

                FoxHttpRequestBuilder foxHttpRequestBuilder = new FoxHttpRequestBuilder(foxHttpMethodParser.getUrl(), foxHttpMethodParser.getRequestType(), foxHttpClient)
                        .setRequestHeader(foxHttpMethodParser.getHeaderFields())
                        .setSkipResponseBody(foxHttpMethodParser.isSkipResponseBody())
                        .setFollowRedirect(foxHttpMethodParser.isFollowRedirect());

                requestCache.put(method, foxHttpRequestBuilder);
            }


            return (T) Proxy.newProxyInstance(serviceInterface.getClassLoader(),
                    new Class[]{serviceInterface}, new FoxHttpAnnotationInvocationHandler(requestCache, responseParsers));
        } catch (FoxHttpException e) {
            throw e;
        } catch (Exception e) {
            throw new FoxHttpRequestException(e);
        }
    }
1069692
function mixinProxying(agent, proxyOpts) {
  agent.proxy = proxyOpts;

  var orig = _.pick(agent, 'createConnection', 'addRequest');

  // Make the tcp or tls connection go to the proxy, ignoring the
  // destination host:port arguments.
  agent.createConnection = function(port, host, options) {
    return orig.createConnection.call(this,
                                      this.proxy.port, this.proxy.host, options);
  };

  // tell the proxy where we really want to go by fully-qualifying the path
  // part. Force a localAddress if one was configured
  agent.addRequest = function(req, host, port, localAddress) {
    req.path = this.proxy.innerProtocol + '//' + host + ':' + port + req.path;
    if (this.proxy.localAddress) {
      localAddress = this.proxy.localAddress;
    }
    return orig.addRequest.call(this, req, host, port, localAddress);
  };
}
852827
public final J4pClientBuilder proxy(String pProxyHost, int pProxyPort, String pProxyUser, String pProxyPass) {
        httpProxy = new Proxy(pProxyHost,pProxyPort, pProxyUser,pProxyPass);
        return this;
    }
425090
private <T> T pluginProxy(final Class<T> type) {
        Object proxy = Proxy.newProxyInstance(classLoader, new Class<?>[]{type}, new InvocationHandler() {
            @Override
            public Object invoke(Object target, Method method, Object[] args) throws Throwable {
                for (Object plugin : getPlugins()) {
                    if (type.isInstance(plugin)) {
                        try {
                            Utils.invoke(plugin, method, 0, args);
                        } catch (Throwable t) {
                            if (!method.getName().equals("startOfScenarioLifeCycle") && !method.getName().equals("endOfScenarioLifeCycle")) {
                                // IntelliJ has its own formatter which doesn't yet implement these methods.
                                throw t;
                            }
                        }
                    }
                }
                return null;
            }
        });
        return type.cast(proxy);
    }
373000
public void connect(Object context) throws Exception {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "connect");
        }

        this.syncObject = new SimpleSync();

        // reset proxy response object
        if (this.proxy != null) {
            this.proxy.setIsProxyResponseValid(false);
        }

        this.syncError = null;
        connectCommon((TCPConnectRequestContext) context);

        if (this.syncError != null) {
            throw this.syncError;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "connect");
        }
    }
552124
def from_dict(config):
        '''
        
        '''
        return ProxyConfig(
            http=config.get('httpProxy'),
            https=config.get('httpsProxy'),
            ftp=config.get('ftpProxy'),
            no_proxy=config.get('noProxy'),
        )
1323725
private void configureProxyServer(ChannelPipeline clientPipeline) {
        if (proxyServerConfiguration != null && sslConfig != null) {
            if (proxyServerConfiguration.getProxyUsername() != null
                    && proxyServerConfiguration.getProxyPassword() != null) {
                clientPipeline.addLast(Constants.PROXY_HANDLER,
                        new HttpProxyHandler(proxyServerConfiguration.getInetSocketAddress(),
                                proxyServerConfiguration.getProxyUsername(),
                                proxyServerConfiguration.getProxyPassword()));
            } else {
                clientPipeline.addLast(Constants.PROXY_HANDLER,
                        new HttpProxyHandler(proxyServerConfiguration.getInetSocketAddress()));
            }
        }
    }
1127784
public static String[] parseProxy(String proxy, List<String> errors) {
        String[] parsedProxyInfo = new String[4];
        if (proxy != null) {
            try {
                URL proxyAsUrl = new  URL(proxy);
                parsedProxyInfo[0] = proxyAsUrl.getHost();
                parsedProxyInfo[1] = String.valueOf(proxyAsUrl.getPort());
                if (proxyAsUrl.getUserInfo() != null) {
                    String[] parsedCred = proxyAsUrl.getUserInfo().split(COLON);
                    parsedProxyInfo[2] = parsedCred[0];
                    if (parsedCred.length > 1) {
                        parsedProxyInfo[3] = parsedCred[1];
                    }
                }

            } catch (MalformedURLException e) {
                errors.add("Malformed proxy url : {}" + e.getMessage());
            }
        }
        return parsedProxyInfo;
    }
1093227
@SuppressWarnings("deprecation")
	ProxyConfig buildProxyConfig() {
		validateProxy();
		return new ProxyConfig(getProxyHost(), getProxyPort(), getProxyUsername(), getProxyPassword(), getProxyBridgePort());
	}
686114
public static Object getTarget(Object proxy) throws Exception {  
          
        if(!AopUtils.isAopProxy(proxy)) {  
            return proxy;//不是代理对象  
        }  
          
        if(AopUtils.isJdkDynamicProxy(proxy)) {  
            Object object = getJdkDynamicProxyTargetObject(proxy);  
            return getTarget(object);
        } else { //cglib  
        	Object object =  getCglibProxyTargetObject(proxy);  
        	return getTarget(object);
        }  
          
          
          
    }
397849
<T> Class<?> transform(Class<T> proxyInterface) {
    try {
      String packageName = proxyInterface.getPackage().getName();
      String genericProxyInterfaceName =
          packageName + "." + PROXY_PREFIX + proxyInterface.getSimpleName();
      try {
        return Class.forName(genericProxyInterfaceName);
      } catch (ClassNotFoundException e) {
        pool.insertClassPath(new ClassClassPath(proxyInterface));
        CtClass copy = pool.getAndRename(proxyInterface.getName(), genericProxyInterfaceName);
        replaceGenericResponseMethods(copy);

        return copy
            .toClass(this.getClass().getClassLoader(), this.getClass().getProtectionDomain());
      }
    } catch (NotFoundException e) {
      throw new RuntimeException(e);
    } catch (CannotCompileException e) {
      throw new RuntimeException(e);
    } catch (BadBytecode e) {
      throw new RuntimeException(e);
    }
  }
352192
def acquire_proxy(self, host, port, use_ssl=False, host_key=None,
                      tunnel=True):
        '''
        '''
        if self._host_filter and not self._host_filter.test(host):
            connection = yield from \
                super().acquire(host, port, use_ssl, host_key)

            return connection

        host_key = host_key or (host, port, use_ssl)
        proxy_host, proxy_port = self._proxy_address

        connection = yield from super().acquire(
            proxy_host, proxy_port, self._proxy_ssl, host_key=host_key
        )
        connection.proxied = True

        _logger.debug('Request for proxy connection.')

        if connection.closed():
            _logger.debug('Connecting to proxy.')
            yield from connection.connect()

            if tunnel:
                yield from self._establish_tunnel(connection, (host, port))

            if use_ssl:
                ssl_connection = yield from connection.start_tls(self._ssl_context)
                ssl_connection.proxied = True
                ssl_connection.tunneled = True

                self._connection_map[ssl_connection] = connection
                connection.wrapped_connection = ssl_connection

                return ssl_connection

        if connection.wrapped_connection:
            ssl_connection = connection.wrapped_connection
            self._connection_map[ssl_connection] = connection
            return ssl_connection
        else:
            return connection
554037
function proxy(options) {
  var proxy = null
    , isSSL = false
    ;

  if (options.protocol === 'https:') {
    isSSL = true;
  }

  // Test the proxy parameter first for priority
  if (proxyOptions) {
    proxy = proxyOptions;
  } else {
    // Test proxy by env
    if (proxyHttpEnv) {
      proxy = proxyHttpEnv;
    } else if (proxyHttpsEnv) {
      proxy = proxyHttpsEnv;
    }
  }

  if (!proxy) {
    return;
  }

  if (isSSL) {
    options.agent = new HttpsProxyAgent(proxy);
  } else {
    options.agent = new HttpProxyAgent(proxy);
  }
}
748253
public static void applyProxy(Proxy use) {
    System.setProperty("java.net.useSystemProxies", "false");
    System.setProperty("http.proxyHost", use.getIp());
    System.setProperty("http.proxyPort", String.valueOf(use.getPort()));
    System.setProperty("https.proxyHost", use.getIp());
    System.setProperty("https.proxyPort", String.valueOf(use.getPort()));
  }