Пример #1
0
        private void TcpClientAccepted(IAsyncResult ar)
        {
            if (stopped)
            {
                return;
            }

            var       listener = (TcpListener)ar.AsyncState;
            TcpClient client   = null;

            try
            {
                client = listener.EndAcceptTcpClient(ar);
            }
            catch
            {
                return;
            }

            listener.BeginAcceptTcpClient(TcpClientAccepted, listener);

            IPAddress loopBack = ((IPEndPoint)listener.LocalEndpoint).Address;
            var       redir    = Tool.Servers.Single(server => server.Loopback.Equals(loopBack));

            if (client != null)
            {
                var worker = new SocketProxyWorker(this, loopBack.ToString(), redir.DNS, redir.Name, client);
                worker.ServerPacketReceived += ServerPacketReceived;
                worker.ClientPacketReceived += ClientPacketReceived;
                if (ClientConnected != null)
                {
                    ClientConnected(this, new ConnectedEventArgs(worker));
                }
            }
        }
Пример #2
0
 public ConnectedEventArgs(SocketProxyWorker client)
 {
     Client = client;
 }