コード例 #1
0
        private ProxySession GetOrCreateProxySession(AcceptedTcpClient acceptedTcpClient)
        {
            ProxySession proxySession;

            if (!TryFindProxySession(acceptedTcpClient, out proxySession))
            {
                var rule = configuration.FindRule(acceptedTcpClient.RemoteEndPoint.Address);

                // TODO: find a better way to do that so it does not block the server from receiving data.
                var destinationClient = new DataStreamingClient(rule.Destination);
                destinationClient.ConnectAsync().Wait();
                proxySession = new ProxySession(acceptedTcpClient, destinationClient);
                allProxySessions.Add(proxySession);
            }
            return(proxySession);
        }
コード例 #2
0
ファイル: ProxySession.cs プロジェクト: fabienDaou/MockTcp
 public ProxySession(AcceptedTcpClient sourceClient, DataStreamingClient destinationClient)
 {
     SourceClient      = sourceClient;
     DestinationClient = destinationClient;
     DestinationClient.DataReceived += DestinationClient_DataReceived;
 }