Example #1
0
        protected virtual async Task HandleAcceptedTcp(TcpClient tcpClient)
        {
            EPPair         epPair     = new EPPair();
            HttpConnection connection = null;

            try {
                epPair = EPPair.FromSocket(tcpClient.Client);
                var myStream = MyStream.FromSocket(tcpClient.Client);
                var stream   = myStream.ToStream();
                connection = this.CreateHttpConnectionObject(tcpClient, stream, epPair);
                if (connection == null)
                {
                    try {
                        tcpClient.Close();
                    } catch (Exception) { }
                    return;
                }
            } catch (Exception e) {
                Logger.exception(e, Logging.Level.Error, $"({epPair}) httpConnection creating");
                return;
            }
            try {
                await connection.Process();
            } catch (Exception e) {
                try {
                    this.OnHttpConnectionException(e, connection);
                } catch (Exception e2) {
                    Logger.exception(e2, Logging.Level.Error, "In OnHttpConnectionExceptionExit");
                }
            }
        }
Example #2
0
        public override void OnNewConnection(TcpClient tcpClient)
        {
            Socket socket     = tcpClient.Client;
            var    epPair     = EPPair.FromSocket(socket);
            var    dataStream = GetMyStreamFromSocket(socket);
            var    dest       = Unsafe.GetOriginalDst(socket, Logger);

            HandleIncommingConnection(InConnectionTcp.Create(this, dest, dataStream, epPair.ToString()));
        }
Example #3
0
        public override void OnNewConnection(TcpClient tcpClient)
        {
            Socket socket     = tcpClient.Client;
            var    epPair     = EPPair.FromSocket(socket);
            var    dataStream = GetMyStreamFromSocket(socket);
            var    dest       = this.dest.WithDefaultPort(listen.Port);

            HandleIncommingConnection(InConnectionTcp.Create(this, dest, dataStream, epPair.ToString()));
        }
Example #4
0
            public SocksInConnection(TcpClient tcp, SocksInAdapter adapter) : base(adapter)
            {
                _eppair   = EPPair.FromSocket(tcp.Client);
                _adapter  = adapter;
                _stream   = adapter.GetMyStreamFromSocket(tcp.Client);
                socks5svr = new Socks5Server(_stream);

                Socks5Server.Methods methods = Socks5Server.Methods.None;
                if (adapter._allowNoAuth)
                {
                    methods |= Socks5Server.Methods.NoAuth;
                }
                if (adapter.users != null)
                {
                    methods |= Socks5Server.Methods.UsernamePassword;
                }
                socks5svr.AcceptMethods = methods;

                outRef = adapter._noAuthOut;

                socks5svr.Auth = Auth;
            }
Example #5
0
 protected SocketStream(Socket socket)
 {
     this.Socket  = socket;
     this._ePPair = EPPair.FromSocket(socket);
     IsUdp        = socket.ProtocolType == ProtocolType.Udp;
 }