private static void AcceptClient(IAsyncResult result) { var client = Listener.EndAcceptTcpClient(result); Console.WriteLine("New connection from " + client.Client.RemoteEndPoint.ToString()); // Connect to remote var server = new TcpClient(); server.Connect(ProxySettings.RemoteEndPoint); var proxy = new Proxy(client.GetStream(), server.GetStream(), new Log(new StreamWriter(GetLogName()), ProxySettings), ProxySettings); Sessions.Add(proxy); foreach (var plugin in Plugins) plugin.SessionInitialize(proxy); proxy.Start(); Listener.BeginAcceptTcpClient(AcceptClient, null); }
private static void AcceptClient(IAsyncResult result) { var client = Listener.EndAcceptTcpClient(result); Console.WriteLine("New connection from " + client.Client.RemoteEndPoint.ToString()); // Connect to remote var server = new TcpClient(); server.Connect(ProxySettings.RemoteEndPoint); var proxy = new Proxy(client.GetStream(), server.GetStream(), new Log(new StreamWriter(GetLogName()), ProxySettings), ProxySettings); Sessions.Add(proxy); foreach (var plugin in Plugins) { plugin.SessionInitialize(proxy); } proxy.Start(); Listener.BeginAcceptTcpClient(AcceptClient, null); }
private static void AcceptConnection(IAsyncResult result) { var local = LocalListener.EndAccept(result); Console.WriteLine("Recieved connection from " + local.RemoteEndPoint + ", proxying to " + settings.RemoteEndPoint); var remote = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); remote.Connect(settings.RemoteEndPoint); var proxy = new Proxy(new FileLogProvider(settings, GetFileName((IPEndPoint)local.RemoteEndPoint)), settings); proxy.Start(local, remote); if (!settings.SingleSession) LocalListener.BeginAccept(AcceptConnection, null); }