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); }
public ProxySession(AcceptedTcpClient sourceClient, DataStreamingClient destinationClient) { SourceClient = sourceClient; DestinationClient = destinationClient; DestinationClient.DataReceived += DestinationClient_DataReceived; }