Create a Network proxy for the given proxy settings.
339599
def _create_proxy(proxy_setting):
        """"""
        proxy = QNetworkProxy()
        proxy_scheme = proxy_setting['scheme']
        proxy_host = proxy_setting['host']
        proxy_port = proxy_setting['port']
        proxy_username = proxy_setting['username']
        proxy_password = proxy_setting['password']
        proxy_scheme_host = '{0}://{1}'.format(proxy_scheme, proxy_host)
        proxy.setType(QNetworkProxy.HttpProxy)

        if proxy_scheme_host:
            # proxy.setHostName(proxy_scheme_host)  # does not work with scheme
            proxy.setHostName(proxy_host)

        if proxy_port:
            proxy.setPort(proxy_port)

        if proxy_username:
            proxy.setUser(proxy_username)

        if proxy_password:
            proxy.setPassword(proxy_password)

        return proxy
364416
def proxies(self, url):
        
        netloc = urllib.parse.urlparse(url).netloc
        proxies = {}
        if settings.PROXIES and settings.PROXIES.get(netloc):
            proxies["http"] = settings.PROXIES[netloc]
            proxies["https"] = settings.PROXIES[netloc]
        elif settings.PROXY_URL:
            proxies["http"] = settings.PROXY_URL
            proxies["https"] = settings.PROXY_URL
        return proxies
992854
def proxy_it(request, port):
    """"""

    # Check if we have websocket proxy configured
    websocket_proxy = request.registry.settings.get("pyramid_notebook.websocket_proxy", "")
    if websocket_proxy.strip():
        r = DottedNameResolver()
        websocket_proxy = r.maybe_resolve(websocket_proxy)

    if "upgrade" in request.headers.get("connection", "").lower():
        if websocket_proxy:
            return websocket_proxy(request, port)
        else:
            # If we run on localhost on pserve, we should never hit here as requests go directly to IPython Notebook kernel, not us
            raise RuntimeError("Websocket proxy support is not configured.")

    proxy_app = WSGIProxyApplication(port)

    return request.get_response(proxy_app)
1252511
private void addProxyConfig(RequestConfig.Builder requestConfigBuilder, HttpClientSettings settings) {
        if (settings.isProxyEnabled() && settings.isAuthenticatedProxy() && settings.getProxyAuthenticationMethods() != null) {
            List<String> apacheAuthenticationSchemes = new ArrayList<String>();

            for (ProxyAuthenticationMethod authenticationMethod : settings.getProxyAuthenticationMethods()) {
                apacheAuthenticationSchemes.add(toApacheAuthenticationScheme(authenticationMethod));
            }

            requestConfigBuilder.setProxyPreferredAuthSchemes(apacheAuthenticationSchemes);
        }
    }
1116873
def _prepare_proxy(self, conn):
        
        conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers)
        conn.connect()
74228
public Proxy createSeleniumProxy() {
    return isEmpty(config.proxyHost())
      ? ClientUtil.createSeleniumProxy(proxy)
      : ClientUtil.createSeleniumProxy(proxy, inetAddressResolver.getInetAddressByName(config.proxyHost()));
  }
957184
private DefaultProxyRoutePlanner createProxyRoutePlanner(HttpSettings settings, HttpAsyncClientBuilder httpClientBuilder) {
        HttpHost proxy = new HttpHost(settings.getProxyUrl().getHost(), settings.getProxyUrl().getPort());
        if (settings.getProxyUser() != null) {
            CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
            String proxyUser = settings.getProxyUser();
            String proxyPassword = settings.getProxyPassword();
            UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(proxyUser, proxyPassword);
            credentialsProvider.setCredentials(new AuthScope(proxy), credentials);
            httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
        }
        return new DefaultProxyRoutePlanner(proxy);
    }
97812
def set_proxy(self, host     = "localhost",
                      port     = 0,
                      user     = "",
                      password = ""):
    
    self.conn.issue_command("SetProxy", host, port, user, password)
1267538
def create_ip(self):
        """"""
        return Ip(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
871804
def set_proxy(proxy_url, transport_proxy=None):
    """"""
    global proxy, PYPI_URL
    PYPI_URL = proxy_url
    proxy = xmlrpc.ServerProxy(
        proxy_url,
        transport=RequestsTransport(proxy_url.startswith('https://')),
        allow_none=True)
889807
def setProxy(self, protocol="http"):
        
        # Setting proxy
        try:
            new = { protocol: self.proxies[protocol]}
            self.br.set_proxies( new )
        except:
            # No proxy defined for that protocol
            pass
164634
def _create_network_config(self):
        
        path = os.path.join(self.working_dir, "etc", "network")
        os.makedirs(path, exist_ok=True)
        open(os.path.join(path, ".gns3_perms"), 'a').close()
        os.makedirs(os.path.join(path, "if-up.d"), exist_ok=True)
        os.makedirs(os.path.join(path, "if-down.d"), exist_ok=True)
        os.makedirs(os.path.join(path, "if-pre-up.d"), exist_ok=True)
        os.makedirs(os.path.join(path, "if-post-down.d"), exist_ok=True)

        if not os.path.exists(os.path.join(path, "interfaces")):
            with open(os.path.join(path, "interfaces"), "w+") as f:
                f.write("""#
# This is a sample network config uncomment lines to configure the network
#

""")
                for adapter in range(0, self.adapters):
                    f.write("""
# Static config for eth{adapter}
#auto eth{adapter}
#iface eth{adapter} inet static
#\taddress 192.168.{adapter}.2
#\tnetmask 255.255.255.0
#\tgateway 192.168.{adapter}.1
#\tup echo nameserver 192.168.{adapter}.1 > /etc/resolv.conf

# DHCP config for eth{adapter}
# auto eth{adapter}
# iface eth{adapter} inet dhcp""".format(adapter=adapter))
        return path
318453
protected Proxy getProxy(final Settings settings, final String serverId, final String host) {
		if (settings == null)
			return null;
		List<Proxy> proxies = settings.getProxies();
		if (proxies == null || proxies.isEmpty())
			return null;

		// search id match first
		if ( serverId != null && !serverId.isEmpty() ) {
			for (Proxy proxy : proxies) {
				if ( proxy.isActive() ) {
					final String proxyId = proxy.getId();
					if ( proxyId != null && !proxyId.isEmpty() ) {
						if ( proxyId.equalsIgnoreCase(serverId) ) {
							if ( ( "http".equalsIgnoreCase( proxy.getProtocol() ) || "https".equalsIgnoreCase( proxy.getProtocol() ) ) ) {
								if ( matchNonProxy( proxy, host ) )
									return null;
								else
									return proxy;
							}
						}
					}
				}
			}
		}

		// search active proxy
		for (Proxy proxy : proxies)
			if ( proxy.isActive() &&
					( "http".equalsIgnoreCase( proxy.getProtocol() ) || "https".equalsIgnoreCase( proxy.getProtocol() ) )
					)
			{
				if ( matchNonProxy( proxy, host ) )
					return null;
				else
					return proxy;
			}

		return null;
	}
168851
def proxy_manager_for(self, proxy, **proxy_kwargs):
        """"""
        try:
            proxy_kwargs['ssl_version'] = ssl.PROTOCOL_TLS
        except AttributeError:
            proxy_kwargs['ssl_version'] = ssl.PROTOCOL_SSLv23
        return super(SSLAdapter, self).proxy_manager_for(proxy, **proxy_kwargs)
1149951
public void setProxy(URI proxy) {
        this.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxy.getHost(), proxy.getPort(), proxy.getScheme()));
    }
182245
def create(annot=None, config=None, id=None, ui=None):
        

        return Network(
            annot=annot,
            config=config,
            id=id,
            ui=ui,
        )
411496
def _configure_proxy(self):
        """"""
        if os.getenv('HTTP_PROXY') or os.getenv('HTTPS_PROXY'):
            # TODO: is this appropriate?
            # don't change proxy settings if the OS already has them configured.
            return True

        proxy_enabled = False
        if self.args.proxy_host is not None and self.args.proxy_port is not None:
            if self.args.proxy_user is not None and self.args.proxy_pass is not None:
                proxy_user = quote(self.args.proxy_user, safe='~')
                proxy_pass = quote(self.args.proxy_pass, safe='~')

                # proxy url with auth
                proxy_url = '{}:{}@{}:{}'.format(
                    proxy_user, proxy_pass, self.args.proxy_host, self.args.proxy_port
                )
            else:
                # proxy url without auth
                proxy_url = '{}:{}'.format(self.args.proxy_host, self.args.proxy_port)

            os.putenv('HTTP_PROXY', 'http://{}'.format(proxy_url))
            os.putenv('HTTPS_PROXY', 'https://{}'.format(proxy_url))

            print(
                'Using Proxy Server: {}{}:{}.'.format(
                    c.Fore.CYAN, self.args.proxy_host, self.args.proxy_port
                )
            )
            proxy_enabled = True
        return proxy_enabled