Esempio n. 1
0
        private void OnConnect(IAsyncResult ar, HandShakeComplete ProtocolComplete, string host, int port)
        {
            try
            {
                Server.EndConnect(ar);
            }
            catch (Exception e)
            {
                ProtocolComplete(e);
                return;
            }
            try
            {
                byte[] command = ConnectCommand(host, port);

                Server.BeginSend(command, 0, command.Length, SocketFlags.None, delegate(IAsyncResult ar2)
                {
                    this.OnSent(ar2, ProtocolComplete);
                }, Server);
            }
            catch (Exception e)
            {
                ProtocolComplete(e);
            }
        }
Esempio n. 2
0
 private void OnSent(IAsyncResult ar, HandShakeComplete ProtocolComplete)
 {
     try
     {
         Server.EndSend(ar);
     }
     catch (Exception e)
     {
         ProtocolComplete(e);
         return;
     }
     try
     {
         byte[] buffer   = new byte[4096]; // 4K ought to be enough for anyone
         int    received = 0;
         Server.BeginReceive(buffer, received, buffer.Length - received, SocketFlags.None, delegate(IAsyncResult ar2)
         {
             this.OnReceive(ar2, ProtocolComplete, buffer, received);
         }, Server);
     }
     catch (Exception e)
     {
         ProtocolComplete(e);
     }
 }
Esempio n. 3
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     ProtocolComplete = callback;
     Buffer           = GetEndPointBytes(remoteEP);
     Server.BeginConnect(proxyEndPoint, new AsyncCallback(this.OnConnect), Server);
     AsyncResult = new IAsyncProxyResult();
     return(AsyncResult);
 }
Esempio n. 4
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override AsyncSocksResult BeginNegotiate(string host, int port, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     handShakeComplete = callback;
     Buffer            = GetHostPortBytes(host, port);
     Server.BeginConnect(proxyEndPoint, OnConnect, Server);
     AsyncResult = new AsyncSocksResult();
     return(AsyncResult);
 }
Esempio n. 5
0
 /// <summary>
 /// Starts negotiating asynchronously with a SOCKS proxy server.
 /// </summary>
 /// <param name="remoteEndPoint">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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override AsyncSocksResult BeginNegotiate(IPEndPoint remoteEndPoint, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     handShakeComplete = callback;
     Buffer            = GetEndPointBytes(remoteEndPoint);
     Server.BeginConnect(proxyEndPoint, OnConnect, Server);
     AsyncResult = new AsyncSocksResult();
     return(AsyncResult);
 }
Esempio n. 6
0
 public override IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     ProtocolComplete = callback;
     base.Buffer      = method_1(remoteEP);
     base.Server.BeginConnect(proxyEndPoint, method_3, base.Server);
     base.AsyncResult = new IAsyncProxyResult(null);
     return(base.AsyncResult);
 }
Esempio n. 7
0
 public override IAsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     ProtocolComplete = callback;
     BdyqsvugsT(method_1(host, port));
     base.Server.BeginConnect(proxyEndPoint, method_4, base.Server);
     base.AsyncResult = new IAsyncProxyResult(null);
     return(base.AsyncResult);
 }
Esempio n. 8
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override IAsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     ProtocolComplete = callback;
     Buffer           = GetHostPortBytes(host, port);
     Server.BeginConnect(proxyEndPoint, new AsyncCallback(this.OnConnect), Server);
     AsyncResult = new IAsyncProxyResult();
     return(AsyncResult);
 }
Esempio n. 9
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     ProtocolComplete = callback;
     Buffer = GetEndPointBytes(remoteEP);
     Server.BeginConnect(proxyEndPoint, new AsyncCallback(this.OnConnect), Server);
     AsyncResult = new IAsyncProxyResult();
     return AsyncResult;
 }
Esempio n. 10
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override IAsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     ProtocolComplete = callback;
     Buffer = GetHostPortBytes(host, port);
     Server.BeginConnect(proxyEndPoint, new AsyncCallback(this.OnConnect), Server);
     AsyncResult = new IAsyncProxyResult();
     return AsyncResult;
 }
Esempio n. 11
0
 /// <summary>
 /// Begins an asynchronous request to resolve a DNS host name or IP address in dotted-quad notation to an IPAddress instance.
 /// </summary>
 /// <param name="host">The host to resolve.</param>
 /// <param name="callback">The method to call when the hostname has been resolved.</param>
 /// <returns>An IAsyncResult instance that references the asynchronous request.</returns>
 /// <exception cref="SocketException">There was an error while trying to resolve the host.</exception>
 internal IAsyncProxyResult BeginDns(string host, HandShakeComplete callback)
 {
     try {
         Dns.BeginGetHostEntry(host, new AsyncCallback(this.OnResolved), this);
         return(new IAsyncProxyResult());
     } catch {
         throw new SocketException();
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Starts the asynchronous authentication process.
        /// </summary>
        /// <param name="callback">The method to call when the authentication is complete.</param>
        public override void BeginAuthenticate(HandShakeComplete callback)
        {
            int length = GetAuthenticationLength();

            Buffer = ArrayPool <byte> .Shared.Rent(length);

            GetAuthenticationBytes(Buffer);
            CallBack = callback;
            Server.BeginSend(Buffer, 0, length, SocketFlags.None, this.OnSent, Server);
        }
Esempio n. 13
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override AsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback,
                                                 IPEndPoint proxyEndPoint, object state)
 {
     ProtocolComplete = callback;
     HandShake        = GetEndPointBytes(remoteEP);
     Server.BeginConnect(proxyEndPoint, OnConnect, Server);
     AsyncResult = new AsyncProxyResult();
     AsyncResult.Init(state);
     return(AsyncResult);
 }
Esempio n. 14
0
 /// <summary>
 /// Starts negotiating asynchronously with the SOCKS 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 SOCKS proxy server.</param>
 /// <param name="state"></param>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override AsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback,
                                                 IPEndPoint proxyEndPoint, object state)
 {
     ProtocolComplete = callback;
     HandShake        = GetHostPortBytes(host, port);
     Server.BeginConnect(proxyEndPoint, OnConnect, Server);
     AsyncResult = new AsyncProxyResult();
     AsyncResult.Init(state);
     return(AsyncResult);
 }
 /// <summary>
 ///     Starts the asynchronous authentication process.
 /// </summary>
 /// <param name="callback">The method to call when the authentication is complete.</param>
 public override void BeginAuthenticate(HandShakeComplete callback)
 {
     CallBack = callback;
     Server.BeginSend(GetAuthenticationBytes(),
                      0,
                      3 + Username.Length + Password.Length,
                      SocketFlags.None,
                      OnSent,
                      Server);
     return;
 }
Esempio n. 16
0
 public override IAsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     // ProtocolComplete = callback;
     // Buffer = GetHostPortBytes(host, port);
     Server.BeginConnect(proxyEndPoint, delegate(IAsyncResult ar)
     {
         this.OnConnect(ar, callback, host, port);
     }, Server);
     IAsyncProxyResult AsyncResult = new IAsyncProxyResult();
     return AsyncResult;
 }
Esempio n. 17
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);
        }
Esempio n. 18
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);
        }
Esempio n. 19
0
 /// <summary>
 /// Begins an asynchronous request to resolve a DNS host name or IP address in dotted-quad notation to an IPAddress instance.
 /// </summary>
 /// <param name="host">The host to resolve.</param>
 /// <param name="callback">The method to call when the hostname has been resolved.</param>
 /// <returns>An IAsyncResult instance that references the asynchronous request.</returns>
 /// <exception cref="SocketException">There was an error while trying to resolve the host.</exception>
 internal AsyncSocksResult BeginDns(string host, HandShakeComplete callback)
 {
     try
     {
         Dns.BeginGetHostEntry(host, OnResolved, this);
         return(new AsyncSocksResult());
     }
     catch
     {
         throw new SocketException();
     }
 }
Esempio n. 20
0
        public override IAsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback, IPEndPoint proxyEndPoint)
        {
            // ProtocolComplete = callback;
            // Buffer = GetHostPortBytes(host, port);
            Server.BeginConnect(proxyEndPoint, delegate(IAsyncResult ar)
            {
                this.OnConnect(ar, callback, host, port);
            }, Server);
            IAsyncProxyResult AsyncResult = new IAsyncProxyResult();

            return(AsyncResult);
        }
Esempio n. 21
0
 internal IAsyncProxyResult BeginDns(string host, HandShakeComplete callback)
 {
     try
     {
         Dns.BeginGetHostEntry(host, method_0, this);
         return(new IAsyncProxyResult(null));
     }
     catch
     {
         throw new SocketException();
     }
 }
Esempio n. 22
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);
        }
Esempio n. 23
0
 internal IAsyncProxyResult BeginDns(string host, HandShakeComplete callback)
 {
     try
     {
         #pragma warning disable 0618
         Dns.BeginResolve(host, new AsyncCallback(OnResolved), this);
         return(new IAsyncProxyResult());
     }
     catch
     {
         throw new SocketException();
     }
 }
Esempio n. 24
0
        private void OnReceive(IAsyncResult ar, HandShakeComplete ProtocolComplete, byte[] buffer, int received)
        {
            try
            {
                int newlyReceived = Server.EndReceive(ar);
                if (newlyReceived <= 0)
                {
                    ProtocolComplete(new SocketException());
                    return;
                }
                received += newlyReceived;

                if (ResponseReady(buffer, received))
                {
                    // end of the header
                    ParseResponse(buffer, received);
                    // if no exception was thrown, then..
                    ProtocolComplete(null);
                }
                else if (received == buffer.Length)
                {
                    throw new ProxyException("Unexpected HTTP proxy response");
                }
                else
                {
                    Server.BeginReceive(buffer, received, buffer.Length - received, SocketFlags.None, delegate(IAsyncResult ar2)
                    {
                        this.OnReceive(ar2, ProtocolComplete, buffer, received);
                    }, Server);
                }
            }
            catch (Exception e)
            {
                ProtocolComplete(e);
            }
        }
Esempio n. 25
0
 public abstract void BeginAuthenticate(HandShakeComplete callback);
Esempio n. 26
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public abstract IAsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback, IPEndPoint proxyEndPoint);
Esempio n. 27
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public abstract IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback,
                                                  IPEndPoint proxyEndPoint);
Esempio n. 28
0
        /// <summary>
        /// Begins an asynchronous request to resolve a DNS host name or IP address in dotted-quad notation to an IPAddress instance.
        /// </summary>
        /// <param name="host">The host to resolve.</param>
        /// <param name="callback">The method to call when the hostname has been resolved.</param>
        /// <returns>An IAsyncResult instance that references the asynchronous request.</returns>
        /// <exception cref="SocketException">There was an error while trying to resolve the host.</exception>
        internal IAsyncProxyResult BeginDns(string host, HandShakeComplete callback)
        {
            try
            {
                Dns.BeginResolve(host, new AsyncCallback(this.OnResolved), this);

                return new IAsyncProxyResult();
            }
            catch
            {
                throw new SocketException();
            }
        }
Esempio n. 29
0
 /// <summary>
 /// Starts the asynchronous authentication process.
 /// </summary>
 /// <param name="callback">The method to call when the authentication is complete.</param>
 public void BeginAuthenticate(HandShakeComplete callback)
 {
     _callBack = callback;
     Endpoint.BeginSend(GetAuthenticationBytes(), 0, 3 + Username.Length + Password.Length, SocketFlags.None, OnSent, Endpoint);
 }
Esempio n. 30
0
 private void OnSent(IAsyncResult ar, HandShakeComplete ProtocolComplete)
 {
     try
     {
         Server.EndSend(ar);
     }
     catch (Exception e)
     {
         ProtocolComplete(e);
         return;
     }
     try
     {
         byte[] buffer = new byte[4096]; // 4K ought to be enough for anyone
         int received = 0;
         Server.BeginReceive(buffer, received, buffer.Length - received, SocketFlags.None, delegate(IAsyncResult ar2)
         {
             this.OnReceive(ar2, ProtocolComplete, buffer, received);
         }, Server);
     }
     catch (Exception e)
     {
         ProtocolComplete(e);
     }
 }
Esempio n. 31
0
        private void OnReceive(IAsyncResult ar, HandShakeComplete ProtocolComplete, byte[] buffer, int received)
        {
            try
            {
                int newlyReceived = Server.EndReceive(ar);
                if (newlyReceived <= 0)
                {
                    ProtocolComplete(new SocketException());
                    return;
                }
                received += newlyReceived;

                if (ResponseReady(buffer, received))
                {
                    // end of the header
                    ParseResponse(buffer, received);
                    // if no exception was thrown, then..
                    ProtocolComplete(null);
                }
                else if (received == buffer.Length)
                {
                    throw new ProxyException("Unexpected HTTP proxy response");
                }
                else
                {
                    Server.BeginReceive(buffer, received, buffer.Length - received, SocketFlags.None, delegate(IAsyncResult ar2)
                    {
                        this.OnReceive(ar2, ProtocolComplete, buffer, received);
                    }, Server);
                }
            }
            catch (Exception e)
            {
                ProtocolComplete(e);
            }
        }
Esempio n. 32
0
        private void OnConnect(IAsyncResult ar, HandShakeComplete ProtocolComplete, string host, int port)
        {
            try
            {
                Server.EndConnect(ar);
            }
            catch (Exception e)
            {
                ProtocolComplete(e);
                return;
            }
            try
            {
                byte[] command = ConnectCommand(host, port);

                Server.BeginSend(command, 0, command.Length, SocketFlags.None, delegate(IAsyncResult ar2)
                {
                    this.OnSent(ar2, ProtocolComplete);
                }, Server);
            }
            catch (Exception e)
            {
                ProtocolComplete(e);
            }
        }
Esempio n. 33
0
 /// <summary>
 /// Starts the asynchronous authentication process.
 /// </summary>
 /// <param name="callback">The method to call when the authentication is complete.</param>
 public override void BeginAuthenticate(HandShakeComplete callback)
 {
     CallBack = callback;
     Server.BeginSend(GetAuthenticationBytes(), 0, GetAuthenticationLength(), SocketFlags.None, new AsyncCallback(this.OnSent), Server);
     return;
 }
Esempio n. 34
0
		/// <summary>
		/// Authenticates the user asynchronously.
		/// </summary>
		/// <param name="callback">The method to call when the authentication is complete.</param>
		/// <remarks>This method immediately calls the callback method.</remarks>
		public override void BeginAuthenticate(HandShakeComplete callback) {
			callback(null);
		}
Esempio n. 35
0
 public override IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     return(BeginNegotiate(remoteEP.Address.ToString(), remoteEP.Port, callback, proxyEndPoint));
 }
Esempio n. 36
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public override IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     throw new NotSupportedException();
 }
Esempio n. 37
0
 /// <summary>
 /// Starts the asynchronous authentication process.
 /// </summary>
 /// <param name="callback">The method to call when the authentication is complete.</param>
 public override void BeginAuthenticate(HandShakeComplete callback)
 {
     this.CallBack = callback;
     this.Server.BeginSend(this.GetAuthenticationBytes(), 0, 3 + this.Username.Length + this.Password.Length, SocketFlags.None, new AsyncCallback(this.OnSent), this.Server);
 }
Esempio n. 38
0
		/// <summary>
		/// Starts the asynchronous authentication process.
		/// </summary>
		/// <param name="callback">The method to call when the authentication is complete.</param>
		public override void BeginAuthenticate(HandShakeComplete callback) {
			CallBack = callback;
			Server.BeginSend(GetAuthenticationBytes(), 0, 3 + Username.Length + Password.Length, SocketFlags.None, new AsyncCallback(this.OnSent), Server);
			return;
		}
Esempio n. 39
0
 public override void BeginAuthenticate(HandShakeComplete callback)
 {
     CallBack = callback;
     base.Server.BeginSend(method_0(), 0, method_1(), SocketFlags.None, method_2, base.Server);
 }
Esempio n. 40
0
		/// <summary>
		/// Authenticates the user asynchronously.
		/// </summary>
		/// <param name="callback">The method to call when the authentication is complete.</param>
		/// <exception cref="ProxyException">Authentication with the proxy server failed.</exception>
		/// <exception cref="ProtocolViolationException">The proxy server uses an invalid protocol.</exception>
		/// <exception cref="SocketException">An operating system error occurs while accessing the Socket.</exception>
		/// <exception cref="ObjectDisposedException">The Socket has been closed.</exception>
		public abstract void BeginAuthenticate(HandShakeComplete callback);
Esempio n. 41
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public abstract IAsyncProxyResult BeginNegotiate(string host, int port, HandShakeComplete callback,
                                                  IPEndPoint proxyEndPoint);
Esempio n. 42
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>
 /// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
 public abstract IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback, IPEndPoint proxyEndPoint);
Esempio n. 43
0
 public override IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeComplete callback, IPEndPoint proxyEndPoint)
 {
     return BeginNegotiate(remoteEP.Address.ToString(), remoteEP.Port, callback, proxyEndPoint);
 }
Esempio n. 44
0
 /// <summary>
 /// Authenticates the user asynchronously.
 /// </summary>
 /// <param name="callback">The method to call when the authentication is complete.</param>
 /// <remarks>This method immediately calls the callback method.</remarks>
 public override void BeginAuthenticate(HandShakeComplete callback)
 {
     callback(null);
 }