Beispiel #1
0
        public void Begin(int PacketSize, int Timeout)
        {
            Client.onClientDisconnected += Client_onClientDisconnected;
            List <AuthTypes> authtypes = Socks5.RequestAuth(this);

            if (authtypes.Count <= 0)
            {
                Client.Send(new byte[] { 0x00, 0xFF });
                Client.Disconnect();
                return;
            }
            else if (Authentication && this.OnClientAuthenticating != null)
            {
                //request login.
                User user = Socks5.RequestLogin(this);
                if (user == null)
                {
                    Client.Disconnect();
                    return;
                }
                LoginStatus status = this.OnClientAuthenticating(this, new SocksAuthenticationEventArgs(user));
                Client.Send(new byte[] { (byte)HeaderTypes.Socks5, (byte)status });
                if (status == LoginStatus.Denied)
                {
                    Client.Disconnect();
                    return;
                }
                else if (status == LoginStatus.Correct)
                {
                    Authenticated = true;
                }
                //read password and invoke.
                //this.OnClientAuthenticating(this, new SocksAuthenticationEventArgs(..));
            }
            else
            {//no username/password required?
                Authenticated = true;
                Client.Send(new byte[] { (byte)HeaderTypes.Socks5, (byte)HeaderTypes.Zero });
            }
            SocksRequest req = Socks5.RequestTunnel(this);

            if (req == null)
            {
                Client.Disconnect(); return;
            }
            SocksTunnel x = new SocksTunnel(this, req, PacketSize, Timeout);

            x.Open();
        }
Beispiel #2
0
 public void Begin(int PacketSize, int Timeout)
 {
     Client.onClientDisconnected += Client_onClientDisconnected;
     List<AuthTypes> authtypes = Socks5.RequestAuth(this);
     if (authtypes.Count <= 0)
     {
         Client.Send(new byte[] { 0x00, 0xFF });
         Client.Disconnect();
         return;
     }
     else if(Authentication && this.OnClientAuthenticating != null)
     {
         //request login.
         User user = Socks5.RequestLogin(this);
         if (user == null)
         {
             Client.Disconnect();
             return;
         }
         LoginStatus status = this.OnClientAuthenticating(this, new SocksAuthenticationEventArgs(user));
         Client.Send(new byte[] { (byte)HeaderTypes.Socks5, (byte)status });
         if (status == LoginStatus.Denied)
         {
             Client.Disconnect();
             return;
         }
         else if (status == LoginStatus.Correct)
         {
             Authenticated = true;
         }
         //read password and invoke.
         //this.OnClientAuthenticating(this, new SocksAuthenticationEventArgs(..));
     }
     else
     {//no username/password required?
         Authenticated = true;
         Client.Send(new byte[] { (byte)HeaderTypes.Socks5, (byte)HeaderTypes.Zero });
     }
     SocksRequest req = Socks5.RequestTunnel(this);
     if (req == null) { Client.Disconnect(); return; }
     SocksTunnel x = new SocksTunnel(this, req, PacketSize, Timeout);
     x.Open();
 }