Return True if it appears we can connect to a SOCKS proxy,
        otherwise False.
193152
async def _detect_proxy(self):
        '''
        '''
        if self.protocol is SOCKS4a:
            remote_address = NetAddress('www.apple.com', 80)
        else:
            remote_address = NetAddress('8.8.8.8', 53)

        sock = await self._connect_one(remote_address)
        if isinstance(sock, socket.socket):
            sock.close()
            return True

        # SOCKSFailure indicates something failed, but that we are likely talking to a
        # proxy
        return isinstance(sock, SOCKSFailure)
179423
def is_authenticated(self):
        
        if self._proxy is None:
            return False
        elif self._proxy.has_authentication():
            return self._proxy.get_authentication().is_valid()
        else:
            return False
723729
public function useSocks5Proxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null)
    {
        return $this->useProxy($proxy_host, $proxy_port, $auth_type, $auth_username, $auth_password, Proxy::SOCKS5);
    }
374885
private void onOK() {
		host = host_text.getText().trim();
		user = user_text.getText();
		password = password_text.getText();

		if (host.length() == 0) {
			warn("Proxy host is not set!");
			return;
		}
		if (socks_group.getSelectedCheckbox() == socks4radio) {
			if (user.length() == 0) {
				warn("User name is not set");
				return;
			}

		} else {
			if (up_check.getState()) {
				if (user.length() == 0) {
					warn("User name is not set.");
					return;
				}
				if (password.length() == 0) {
					warn("Password is not set.");
					return;
				}
			} else if (!none_check.getState()) {
				warn("Please select at least one Authentication Method.");
				return;
			}
		}

		try {
			port = Integer.parseInt(port_text.getText());
		} catch (NumberFormatException nfe) {
			warn("Proxy port is invalid!");
			return;
		}

		mode = OK_MODE;

		if (useThreads) {
			net_thread = new Thread(this);
			net_thread.start();

			info("Looking up host: " + host);
			// System.out.println("Info returned.");
		} else if (!initProxy()) {
			warn("Proxy host is invalid.");
			mode = COMMAND_MODE;
		}

		if (mode == OK_MODE)
			dispose();
	}
838586
boolean isEligible(Address address, @Nullable List<Route> routes) {
    // If this connection is not accepting new exchanges, we're done.
    if (transmitters.size() >= allocationLimit || noNewExchanges) return false;

    // If the non-host fields of the address don't overlap, we're done.
    if (!Internal.instance.equalsNonHost(this.route.address(), address)) return false;

    // If the host exactly matches, we're done: this connection can carry the address.
    if (address.url().host().equals(this.route().address().url().host())) {
      return true; // This connection is a perfect match.
    }

    // At this point we don't have a hostname match. But we still be able to carry the request if
    // our connection coalescing requirements are met. See also:
    // https://hpbn.co/optimizing-application-delivery/#eliminate-domain-sharding
    // https://daniel.haxx.se/blog/2016/08/18/http2-connection-coalescing/

    // 1. This connection must be HTTP/2.
    if (http2Connection == null) return false;

    // 2. The routes must share an IP address.
    if (routes == null || !routeMatchesAny(routes)) return false;

    // 3. This connection's server certificate's must cover the new host.
    if (address.hostnameVerifier() != OkHostnameVerifier.INSTANCE) return false;
    if (!supportsUrl(address.url())) return false;

    // 4. Certificate pinning must match the host.
    try {
      address.certificatePinner().check(address.url().host(), handshake().peerCertificates());
    } catch (SSLPeerUnverifiedException e) {
      return false;
    }

    return true; // The caller's address can be carried by this connection.
  }
536372
private boolean isTransportSecure(HttpServletRequest req) {
		String url = req.getRequestURL().toString();
		if (req.getScheme().equals("https")) {
			return true;
		}

		String value = req.getHeader("X-Forwarded-Proto");
		if (value != null && value.toLowerCase().equals("https")) {
			return true;
		}
		return false;
	}
1233816
public function isSslConnection()
	{
		$serverSSLVar = $this->input->server->getString('HTTPS', '');

		if (!empty($serverSSLVar) && strtolower($serverSSLVar) !== 'off')
		{
			return true;
		}

		$serverForwarderProtoVar = $this->input->server->getString('HTTP_X_FORWARDED_PROTO', '');

		return !empty($serverForwarderProtoVar) && strtolower($serverForwarderProtoVar) === 'https';
	}
18953
def is_available(self):
        
        if self.scheme in NOOP_PROTOCOLS:
            return True

        if not self.port:
            raise RuntimeError('port is required')

        s = socket.socket()
        try:
            s.connect((self.host, self.port))
        except Exception:
            return False
        else:
            return True
1336348
function SOCKS() {
  if (!(this instanceof SOCKS))
    return new SOCKS();

  EventEmitter.call(this);

  this.socket = new net.Socket();
  this.state = SOCKS.states.INIT;
  this.target = SOCKS.states.INIT;
  this.destHost = '0.0.0.0';
  this.destPort = 0;
  this.username = '';
  this.password = '';
  this.name = 'localhost';
  this.destroyed = false;
  this.timeout = null;
  this.proxied = false;
}
417908
async def _create_proxy_connection(self, req, *args, **kwargs):
        
        if req.proxy.scheme == 'http':
            return await super()._create_proxy_connection(req, *args, **kwargs)
        else:
            return await self._create_socks_connection(req=req)
724604
public function useSocks4Proxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null)
    {
        return $this->useProxy($proxy_host, $proxy_port, $auth_type, $auth_username, $auth_password, Proxy::SOCKS4);
    }
815875
def ignore_proxy_host (self):
        """"""
        if urllib.proxy_bypass(self.host):
            return True
        no_proxy = os.environ.get("no_proxy")
        if no_proxy:
            entries = [parse_host_port(x) for x in no_proxy.split(",")]
            for host, port in entries:
                if host.lower() == self.host and port == self.port:
                    return True
        return False
690210
def is_running(self):
        """"""
        try:
            result = requests.get(self.proxy_url)
        except RequestException:
            return False

        if 'ZAP-Header' in result.headers.get('Access-Control-Allow-Headers', []):
            return True

        raise ZAPError('Another process is listening on {0}'.format(self.proxy_url))
469149
def valid(self):
        
        return True if self.webdav.valid() and self.proxy.valid() else False
596195
private static boolean isAvailable(int thePort) {
		ourLog.info("Testing a bind on thePort {}", thePort);
		try (ServerSocket ss = new ServerSocket()) {
			ss.setReuseAddress(true);
			ss.bind(new InetSocketAddress("0.0.0.0", thePort));
			try (DatagramSocket ds = new DatagramSocket()) {
				ds.setReuseAddress(true);
				ds.connect(new InetSocketAddress("127.0.0.1", thePort));
				ourLog.info("Successfully bound thePort {}", thePort);
			} catch (IOException e) {
				ourLog.info("Failed to bind thePort {}: {}", thePort, e.toString());
				return false;
			}
		} catch (IOException e) {
			ourLog.info("Failed to bind thePort {}: {}", thePort, e.toString());
			return false;
		}

		try (ServerSocket ss = new ServerSocket()) {
			ss.setReuseAddress(true);
			ss.bind(new InetSocketAddress("localhost", thePort));
		} catch (IOException e) {
			ourLog.info("Failed to bind thePort {}: {}", thePort, e.toString());
			return false;
		}

		return true;
	}
71622
def _get_ssl_sock(self):
        """"""
        assert self.scheme == u"https", self
        raw_connection = self.url_connection.raw._connection
        if raw_connection.sock is None:
            # sometimes the socket is not yet connected
            # see https://github.com/kennethreitz/requests/issues/1966
            raw_connection.connect()
        return raw_connection.sock
830110
public function connect()
    {
        if ($this->ssl !== false) {
            $function = 'ftp_ssl_connect';
        } else {
            $function = 'ftp_connect';
        }

        $result = call_user_func_array($function, array($this->host, $this->port, $this->timeout));

        if (!$result) {
            return false;
        } else {
            $this->stream = $result;
            return true;
        }
    }