Пример #1
0
        public void Start(int PacketSize, int Timeout)
        {

            Client.ClientDisconnecting += ClientClientDisconnecting;

            SocksEncryption w = null;
            if (Client == null)
            {
                this.Dispose();
                return;
            }

            Authenticated = AuthenticateConnection(ref w);
            //Request Site Data.
            if (Authenticated == 1)
            {
                w = new SocksEncryption();
                w.SetType(AuthTypes.Login);
                SocksRequest req = Socks5.RequestTunnel(this, w);
                if (req == null) { Client.Disconnect(); return; }
                req1 = new SocksRequest(req.StreamType, req.Type, req.Address, req.Port);
                //call on plugins for connect callbacks.
                foreach (ConnectHandler conn in PluginLoader.LoadPlugin(typeof(ConnectHandler)))
                    if (conn.Enabled)
                        if (conn.OnConnect(req1) == false)
                        {
                            req.Error = SocksError.Failure;
                            Client.Send(req.GetData(true));

                            Client.Disconnect();
                            return;
                        }
                //Send Tunnel Data back.
                SocksTunnel x = new SocksTunnel(this, req, req1, PacketSize, Timeout);
                x.TunnelDisposing += x_TunnelDisposing;
                x.Open();
            }
            else if (Authenticated == 2)
            {
                SocksRequest req = Socks5.RequestTunnel(this, w);
                if (req == null) { Client.Disconnect(); return; }
                req1 = new SocksRequest(req.StreamType, req.Type, req.Address, req.Port);
                if (PluginLoader.LoadPlugin(typeof(ConnectHandler)).Cast<ConnectHandler>().Where(conn => conn.Enabled).Any(conn => conn.OnConnect(req1) == false))
                {
                    req.Error = SocksError.Failure;
                    Client.Send(req.GetData(true));
                    Client.Disconnect();
                    return;
                }
                //Send Tunnel Data back.
                SocksSpecialTunnel x = new SocksSpecialTunnel(this, w, req, req1, PacketSize, Timeout);
                x.TunnelDisposing += x_TunnelDisposing;
                x.Start();
            }
        }
Пример #2
0
        public void Start(int PacketSize, int Timeout)
        {
            Client.ClientDisconnecting += ClientClientDisconnecting;

            SocksEncryption w = null;

            if (Client == null)
            {
                this.Dispose();
                return;
            }

            Authenticated = AuthenticateConnection(ref w);
            //Request Site Data.
            if (Authenticated == 1)
            {
                w = new SocksEncryption();
                w.SetType(AuthTypes.Login);
                SocksRequest req = Socks5.RequestTunnel(this, w);
                if (req == null)
                {
                    Client.Disconnect(); return;
                }
                req1 = new SocksRequest(req.StreamType, req.Type, req.Address, req.Port);
                //call on plugins for connect callbacks.
                foreach (ConnectHandler conn in PluginLoader.LoadPlugin(typeof(ConnectHandler)))
                {
                    if (conn.Enabled)
                    {
                        if (conn.OnConnect(req1) == false)
                        {
                            req.Error = SocksError.Failure;
                            Client.Send(req.GetData(true));

                            Client.Disconnect();
                            return;
                        }
                    }
                }
                //Send Tunnel Data back.
                SocksTunnel x = new SocksTunnel(this, req, req1, PacketSize, Timeout);
                x.TunnelDisposing += x_TunnelDisposing;
                x.Open();
            }
            else if (Authenticated == 2)
            {
                SocksRequest req = Socks5.RequestTunnel(this, w);
                if (req == null)
                {
                    Client.Disconnect(); return;
                }
                req1 = new SocksRequest(req.StreamType, req.Type, req.Address, req.Port);
                if (PluginLoader.LoadPlugin(typeof(ConnectHandler)).Cast <ConnectHandler>().Where(conn => conn.Enabled).Any(conn => conn.OnConnect(req1) == false))
                {
                    req.Error = SocksError.Failure;
                    Client.Send(req.GetData(true));
                    Client.Disconnect();
                    return;
                }
                //Send Tunnel Data back.
                SocksSpecialTunnel x = new SocksSpecialTunnel(this, w, req, req1, PacketSize, Timeout);
                x.TunnelDisposing += x_TunnelDisposing;
                x.Start();
            }
        }