Connects using websocket protocol
@param string $target Our Target on RemoteServer
@return string
169933
public function connect($target='/websocket/')
	{
		if($this->connected) {
			return $this->sessionId;
		}
		
		$this->fd = stream_socket_client($this->serverHost . ':' . $this->serverPort, $errno, $errstr);

		if (!$this->fd) {
			throw new \RuntimeException('Could not open socket. Reason: ' . $errstr);
		}

        $response = $this->upgradeProtocol($target);

		$this->verifyResponse($response);

		$payload = json_decode($this->read());

		if ($payload[0] != WAMPProtocol::MSG_WELCOME) {
			throw new \RuntimeException('WAMP Server did not send welcome message.');
		}
		
		$this->sessionId = $payload[1];
		return $this->sessionId;
	}
686484
function _connect()
    {
        $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $this->connectionTimeout);
        if (!$this->fsock) {
            user_error(rtrim("Cannot connect to {$this->host}:{$this->port}. Error $errno. $errstr"));
            return false;
        }

        $this->server_identification = $init_line = fgets($this->fsock, 255);

        if (defined('NET_SSH1_LOGGING')) {
            $this->_append_log('<-', $this->server_identification);
            $this->_append_log('->', $this->identifier . "\r\n");
        }

        if (!preg_match('#SSH-([0-9\.]+)-(.+)#', $init_line, $parts)) {
            user_error('Can only connect to SSH servers');
            return false;
        }
        if ($parts[1][0] != 1) {
            user_error("Cannot connect to SSH $parts[1] servers");
            return false;
        }

        fputs($this->fsock, $this->identifier."\r\n");

        $response = $this->_get_binary_packet();
        if ($response[self::RESPONSE_TYPE] != NET_SSH1_SMSG_PUBLIC_KEY) {
            user_error('Expected SSH_SMSG_PUBLIC_KEY');
            return false;
        }

        $anti_spoofing_cookie = $this->_string_shift($response[self::RESPONSE_DATA], 8);

        $this->_string_shift($response[self::RESPONSE_DATA], 4);

        if (strlen($response[self::RESPONSE_DATA]) < 2) {
            return false;
        }
        $temp = unpack('nlen', $this->_string_shift($response[self::RESPONSE_DATA], 2));
        $server_key_public_exponent = new BigInteger($this->_string_shift($response[self::RESPONSE_DATA], ceil($temp['len'] / 8)), 256);
        $this->server_key_public_exponent = $server_key_public_exponent;

        if (strlen($response[self::RESPONSE_DATA]) < 2) {
            return false;
        }
        $temp = unpack('nlen', $this->_string_shift($response[self::RESPONSE_DATA], 2));
        $server_key_public_modulus = new BigInteger($this->_string_shift($response[self::RESPONSE_DATA], ceil($temp['len'] / 8)), 256);

        $this->server_key_public_modulus = $server_key_public_modulus;

        $this->_string_shift($response[self::RESPONSE_DATA], 4);

        if (strlen($response[self::RESPONSE_DATA]) < 2) {
            return false;
        }
        $temp = unpack('nlen', $this->_string_shift($response[self::RESPONSE_DATA], 2));
        $host_key_public_exponent = new BigInteger($this->_string_shift($response[self::RESPONSE_DATA], ceil($temp['len'] / 8)), 256);
        $this->host_key_public_exponent = $host_key_public_exponent;

        if (strlen($response[self::RESPONSE_DATA]) < 2) {
            return false;
        }
        $temp = unpack('nlen', $this->_string_shift($response[self::RESPONSE_DATA], 2));
        $host_key_public_modulus = new BigInteger($this->_string_shift($response[self::RESPONSE_DATA], ceil($temp['len'] / 8)), 256);

        $this->host_key_public_modulus = $host_key_public_modulus;

        $this->_string_shift($response[self::RESPONSE_DATA], 4);

        // get a list of the supported ciphers
        if (strlen($response[self::RESPONSE_DATA]) < 4) {
            return false;
        }
        extract(unpack('Nsupported_ciphers_mask', $this->_string_shift($response[self::RESPONSE_DATA], 4)));

        foreach ($this->supported_ciphers as $mask => $name) {
            if (($supported_ciphers_mask & (1 << $mask)) == 0) {
                unset($this->supported_ciphers[$mask]);
            }
        }

        // get a list of the supported authentications
        if (strlen($response[self::RESPONSE_DATA]) < 4) {
            return false;
        }
        extract(unpack('Nsupported_authentications_mask', $this->_string_shift($response[self::RESPONSE_DATA], 4)));
        foreach ($this->supported_authentications as $mask => $name) {
            if (($supported_authentications_mask & (1 << $mask)) == 0) {
                unset($this->supported_authentications[$mask]);
            }
        }

        $session_id = pack('H*', md5($host_key_public_modulus->toBytes() . $server_key_public_modulus->toBytes() . $anti_spoofing_cookie));

        $session_key = Random::string(32);
        $double_encrypted_session_key = $session_key ^ str_pad($session_id, 32, chr(0));

        if ($server_key_public_modulus->compare($host_key_public_modulus) < 0) {
            $double_encrypted_session_key = $this->_rsa_crypt(
                $double_encrypted_session_key,
                array(
                    $server_key_public_exponent,
                    $server_key_public_modulus
                )
            );
            $double_encrypted_session_key = $this->_rsa_crypt(
                $double_encrypted_session_key,
                array(
                    $host_key_public_exponent,
                    $host_key_public_modulus
                )
            );
        } else {
            $double_encrypted_session_key = $this->_rsa_crypt(
                $double_encrypted_session_key,
                array(
                    $host_key_public_exponent,
                    $host_key_public_modulus
                )
            );
            $double_encrypted_session_key = $this->_rsa_crypt(
                $double_encrypted_session_key,
                array(
                    $server_key_public_exponent,
                    $server_key_public_modulus
                )
            );
        }

        $cipher = isset($this->supported_ciphers[$this->cipher]) ? $this->cipher : self::CIPHER_3DES;
        $data = pack('C2a*na*N', NET_SSH1_CMSG_SESSION_KEY, $cipher, $anti_spoofing_cookie, 8 * strlen($double_encrypted_session_key), $double_encrypted_session_key, 0);

        if (!$this->_send_binary_packet($data)) {
            user_error('Error sending SSH_CMSG_SESSION_KEY');
            return false;
        }

        switch ($cipher) {
            //case self::CIPHER_NONE:
            //    $this->crypto = new \phpseclib\Crypt\Null();
            //    break;
            case self::CIPHER_DES:
                $this->crypto = new DES();
                $this->crypto->disablePadding();
                $this->crypto->enableContinuousBuffer();
                $this->crypto->setKey(substr($session_key, 0,  8));
                break;
            case self::CIPHER_3DES:
                $this->crypto = new TripleDES(TripleDES::MODE_3CBC);
                $this->crypto->disablePadding();
                $this->crypto->enableContinuousBuffer();
                $this->crypto->setKey(substr($session_key, 0, 24));
                break;
            //case self::CIPHER_RC4:
            //    $this->crypto = new RC4();
            //    $this->crypto->enableContinuousBuffer();
            //    $this->crypto->setKey(substr($session_key, 0,  16));
            //    break;
        }

        $response = $this->_get_binary_packet();

        if ($response[self::RESPONSE_TYPE] != NET_SSH1_SMSG_SUCCESS) {
            user_error('Expected SSH_SMSG_SUCCESS');
            return false;
        }

        $this->bitmap = self::MASK_CONNECTED;

        return true;
    }
464239
protected function createLink($source, $target)
    {
        $success = $this->filesystem->relativeSymlink($source, $target);
        if (!$success) {
            throw new RuntimeException("Could not create symlink at $target");
        }
    }
1110691
protected function _parseExtensionDef($target)
    {
        $paths = array();
        if (!empty($target['paths'])) {
            $paths = array_map(array($this, '_replacePathConstants'), (array)$target['paths']);
        }
        $target['paths'] = $paths;
        if (!empty($target['cachePath'])) {
            $path = $this->_replacePathConstants($target['cachePath']);
            $target['cachePath'] = rtrim($path, '/') . '/';
        }
        return $target;
    }
399035
public function targetSerialize($target = self::SER_DEFAULT, $params = null)
    {
        return $this->format($this->format);
    }
456520
public function prependTo($target)
    {
        $target_result = $this->getTargetResult($target);

        $target_result->prepend($this);
        $this->remove();

        return $target_result;
    }
175881
public function getPageLink($navId, $target, $lang = null)
    {
        $linkQuery = Yii::$app->menu->find();
        $linkQuery->where(['nav_id' => $navId]);
        $linkQuery->with(['hidden']);
        if ($lang) {
            $linkQuery->lang($lang);
        }
        $link = $linkQuery->one();
        
        // if a page is found, set the target value from the config.
        if ($link) {
            $link->setTarget($target);
        }
        
        return $link;
    }
64822
public static function a(string $text, string $target = null): string
    {
        return preg_replace('@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@',
          "<a href=\"\$1\"" . ($target != null ? " target=\"{$target}\"" : '') . ">$1</a>", $text);
    }
780941
protected final ChannelFuture doConnect(InetSocketAddress target)
	{
		ChannelHandler fixHandler=fixHandlerBeforeConnect(channelInitFix(handler));//修正handler
		return doBooterConnect(target, fixHandler);
	}
994755
public function connect($target = '/')
    {
        $this->target = $target;

        if ($this->connected) {
            return $this->sessionId;
        }

        $this->socket = @stream_socket_client($this->endpoint, $errno, $errstr);

        if (!$this->socket) {
            throw new BadResponseException('Could not open socket. Reason: ' . $errstr);
        }

        $response = $this->upgradeProtocol($this->target);

        $this->verifyResponse($response);

        $payload = json_decode($this->read());

        if ($payload[0] != Protocol::MSG_WELCOME) {
            throw new BadResponseException('WAMP Server did not send welcome message.');
        }

        $this->sessionId = $payload[1];

        $this->connected = true;

        return $this->sessionId;
    }
342012
public function getEdge( $source, $target )
	{
		if( $source->getNodeName() < $target->getNodeName() )
			return $this->edgeSet->getEdge( $source, $target );
		else
			return $this->edgeSet->getEdge( $target, $source );
	}
471355
public function connect($host, $port = 80, $secure = false)
    {
        // If no proxy is set, fall back to Socket adapter
        if (!$this->config['proxy_host']) {
            return parent::connect($host, $port, $secure);
        }

        /* Url might require stream context even if proxy connection doesn't */
        if ($secure) {
            $this->config['sslusecontext'] = true;
        }

        // Connect (a non-secure connection) to the proxy server
        return parent::connect(
            $this->config['proxy_host'],
            $this->config['proxy_port'],
            false
        );
    }
446331
public function connect($host = null, $port = null)
    {
        return $this->driver->connect(
            $host ? $host : $this->host,
            $port ? $port : $this->port
        );
    }
813309
public function setTarget($target) {
        if (strpos($target, '%s') === false) {
            throw new \InvalidArgumentException('Searchable target url should contain \'%s\'.');
        }
        $this->target = $target;
        return $this;
    }
966238
public function remoteUpload($url, $target)
	{
		$tmp_name = md5($url);
		$tmp_path = Storage::config('tmp_path').'/'.$tmp_name;
		
		if (!$this->remoteDownload($url, $tmp_path)) {
			return false;
		}
		
		return $this->upload($tmp_path, $target);
	}
26318
public function Target($Target = FALSE) {
      if ($Target === FALSE) {
         $Target = $this->Form->GetFormValue('Target', FALSE);
         if (!$Target)
            $Target = $this->Request->Get('Target', '/');
      }
      
      // Make sure that the target is a valid url.
      if (!preg_match('`(^https?://)`', $Target)) {
         $Target = '/'.ltrim($Target, '/');
         
         // Never redirect back to signin.
         if (preg_match('`^/entry/signin`i', $Target))
            $Target = '/';
      } else {
         $MyHostname = parse_url(Gdn::Request()->Domain(),PHP_URL_HOST);
         $TargetHostname = parse_url($Target, PHP_URL_HOST);
         
         // Only allow external redirects to trusted domains.
         $TrustedDomains = C('Garden.TrustedDomains', TRUE);
         
         if (is_array($TrustedDomains)) {
            // Add this domain to the trusted hosts.
            $TrustedDomains[] = $MyHostname;
            $Sender->EventArguments['TrustedDomains'] = &$TrustedDomains;
            $this->FireEvent('BeforeTargetReturn');
         }
			
         if ($TrustedDomains === TRUE) {
            return $Target;
			} elseif (count($TrustedDomains) == 0) {
				// Only allow http redirects if they are to the same host name.
				if ($MyHostname != $TargetHostname)
					$Target = '';
			} else {
				// Loop the trusted domains looking for a match
				$Match = FALSE;
				foreach ($TrustedDomains as $TrustedDomain) {
					if (StringEndsWith($TargetHostname, $TrustedDomain, TRUE))
						$Match = TRUE;
				}
				if (!$Match)
					$Target = '';
			}
      }
      return $Target;
   }
993466
protected function _connect($remote)
    {
        $errorNum = 0;
        $errorStr = '';

        // open connection
        $this->_socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);

        if ($this->_socket === false) {
            if ($errorNum == 0) {
                $errorStr = 'Could not open socket';
            }
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            // require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception($errorStr);
        }

        if (($result = $this->_setStreamTimeout(self::TIMEOUT_CONNECTION)) === false) {
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            // require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception('Could not set stream timeout');
        }

        return $result;
    }