예제 #1
0
 /// <summary>
 /// Starts negotiating asynchronously with the HTTPS server.
 /// </summary>
 /// <param name="host">The host to connect to.</param>
 /// <param name="port">The port to connect to.</param>
 /// <param name="callback">The method to call when the negotiation is complete.</param>
 /// <param name="proxyEndPoint">The IPEndPoint of the HTTPS proxy server.</param>
 /// <param name="state">The state.</param>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override IAsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback,
                                                  IPEndPoint proxyEndPoint, object state)
 {
     ProtocolComplete = callback;
     Buffer           = GetConnectBytes(host, port);
     Server.BeginConnect(proxyEndPoint, this.OnConnect, Server);
     AsyncResult = new IAsyncProxyResult(state);
     return(AsyncResult);
 }
예제 #2
0
        /// <summary>
        /// Starts negotiating asynchronously with a SOCKS proxy server.
        /// </summary>
        /// <param name="remoteEP">An IPEndPoint that represents the remote device.</param>
        /// <param name="callback">The method to call when the connection has been established.</param>
        /// <param name="proxyEndPoint">The IPEndPoint of the SOCKS proxy server.</param>
        /// <param name="state">The state.</param>
        /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
        public override IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback,
                                                         IPEndPoint proxyEndPoint, object state)
        {
            ProtocolComplete = callback;
            Buffer           = ArrayPool <byte> .Shared.Rent(9 + Username.Length);

            BufferCount = GetEndPointBytes(remoteEP, Buffer);
            Server.BeginConnect(proxyEndPoint, OnConnect, Server);
            AsyncResult = new IAsyncProxyResult(state);
            return(AsyncResult);
        }
예제 #3
0
        /// <summary>
        /// Starts negotiating asynchronously with a SOCKS proxy server.
        /// </summary>
        /// <param name="host">The remote server to connect to.</param>
        /// <param name="port">The remote port to connect to.</param>
        /// <param name="callback">The method to call when the connection has been established.</param>
        /// <param name="proxyEndPoint">The IPEndPoint of the SOCKS proxy server.</param>
        /// <param name="state">The state.</param>
        /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
        public override IAsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback,
                                                         IPEndPoint proxyEndPoint, object state)
        {
            ProtocolComplete = callback;
            Buffer           = ArrayPool <byte> .Shared.Rent(10 + Username.Length + host.Length);

            BufferCount = GetHostPortBytes(host, port, Buffer);
            Server.BeginConnect(proxyEndPoint, OnConnect, Server);
            AsyncResult = new IAsyncProxyResult(state);
            return(AsyncResult);
        }
예제 #4
0
        /// <summary>
        /// Starts negotiating asynchronously with the SOCKS server.
        /// </summary>
        /// <param name="remoteEP">An IPEndPoint that represents the remote device.</param>
        /// <param name="callback">The method to call when the negotiation is complete.</param>
        /// <param name="proxyEndPoint">The IPEndPoint of the SOCKS proxy server.</param>
        /// <param name="state">The state.</param>
        /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
        public override IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback,
                                                         IPEndPoint proxyEndPoint, object state)
        {
            ProtocolComplete = callback;
            Buffer           = ArrayPool <byte> .Shared.Rent(Math.Max(258, 13 + Username.Length + Password.Length));

            // first {ConnectOffset} bytes are reserved for authentication
            _handShakeLength = GetEndPointBytes(remoteEP, Buffer.AsMemory(ConnectOffset));
            Server.BeginConnect(proxyEndPoint, this.OnConnect, Server);
            AsyncResult = new IAsyncProxyResult(state);
            return(AsyncResult);
        }