예제 #1
0
        ///<summary>Called when we have received some data from the client.</summary>
        ///<param name="ar">The result of the asynchronous operation.</param>
        private void OnStartSocksProtocol(IAsyncResult ar)
        {
            int Ret;

            try
            {
                Ret = ClientSocket.EndReceive(ar);
                if (Ret <= 0)
                {
                    Dispose();
                    return;
                }
                if (Buffer[0] == 4)
                { //SOCKS4 Protocol
                    if (MustAuthenticate)
                    {
                        Dispose();
                        return;
                    }
                    else
                    {
                        Handler = new Socks4Handler(ClientSocket, new NegotiationCompleteDelegate(this.OnEndSocksProtocol));
                    }
                }
                else if (Buffer[0] == 5)
                { //SOCKS5 Protocol
                    if (MustAuthenticate && AuthList == null)
                    {
                        Dispose();
                        return;
                    }
                    Handler = new Socks5Handler(ClientSocket, new NegotiationCompleteDelegate(this.OnEndSocksProtocol), AuthList);
                }
                else
                {
                    Dispose();
                    return;
                }
                Handler.StartNegotiating();
            }
            catch
            {
                Dispose();
            }
        }
예제 #2
0
 ///<summary>Called when we have received some data from the client.</summary>
 ///<param name="ar">The result of the asynchronous operation.</param>
 private void OnStartSocksProtocol(IAsyncResult ar)
 {
     int Ret;
     try {
     Ret = ClientSocket.EndReceive(ar);
     if (Ret <= 0) {
         Dispose();
         return;
     }
     if (Buffer[0] == 4) { //SOCKS4 Protocol
         if (MustAuthenticate) {
             Dispose();
             return;
         } else {
             Handler = new Socks4Handler(ClientSocket, new NegotiationCompleteDelegate(this.OnEndSocksProtocol));
         }
     } else if(Buffer[0] == 5) { //SOCKS5 Protocol
         if (MustAuthenticate && AuthList == null) {
             Dispose();
             return;
         }
         Handler = new Socks5Handler(ClientSocket, new NegotiationCompleteDelegate(this.OnEndSocksProtocol), AuthList);
     } else {
         Dispose();
         return;
     }
     Handler.StartNegotiating();
     } catch {
     Dispose();
     }
 }