/// <summary> /// Constructor to initialize the proxy /// </summary> internal SessionEventArgs(int bufferSize, ProxyEndPoint endPoint, Func <SessionEventArgs, Task> httpResponseHandler) { this.bufferSize = bufferSize; this.httpResponseHandler = httpResponseHandler; ProxyClient = new ProxyClient(); WebSession = new HttpWebClient(bufferSize); LocalEndPoint = endPoint; WebSession.ProcessId = new Lazy <int>(() => { if (RunTime.IsWindows) { var remoteEndPoint = (IPEndPoint)ProxyClient.TcpClient.Client.RemoteEndPoint; //If client is localhost get the process id if (NetworkHelper.IsLocalIpAddress(remoteEndPoint.Address)) { return(NetworkHelper.GetProcessIdFromPort(remoteEndPoint.Port, endPoint.IpV6Enabled)); } //can't access process Id of remote request from remote machine return(-1); } throw new PlatformNotSupportedException(); }); }
protected SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint, CancellationTokenSource cancellationTokenSource, Request request) : this(server, endPoint, cancellationTokenSource) { CancellationTokenSource = cancellationTokenSource; ProxyClient = new ProxyClient(); WebSession = new HttpWebClient(request); LocalEndPoint = endPoint; WebSession.ProcessId = new Lazy <int>(() => { if (RunTime.IsWindows) { var remoteEndPoint = ClientEndPoint; // If client is localhost get the process id if (NetworkHelper.IsLocalIpAddress(remoteEndPoint.Address)) { var ipVersion = endPoint.IpV6Enabled ? IpVersion.Ipv6 : IpVersion.Ipv4; return(TcpHelper.GetProcessIdByLocalPort(ipVersion, remoteEndPoint.Port)); } // can't access process Id of remote request from remote machine return(-1); } throw new PlatformNotSupportedException(); }); }
/// <summary> /// Constructor to initialize the proxy /// </summary> internal SessionEventArgs(int bufferSize, Func <SessionEventArgs, Task> httpResponseHandler) { this.bufferSize = bufferSize; this.httpResponseHandler = httpResponseHandler; ProxyClient = new ProxyClient(); WebSession = new HttpWebClient(); }
protected SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint, CancellationTokenSource cancellationTokenSource, Request request) : this(server) { CancellationTokenSource = cancellationTokenSource; ProxyClient = new ProxyClient(); HttpClient = new HttpWebClient(request); LocalEndPoint = endPoint; HttpClient.ProcessId = new Lazy <int>(() => ProxyClient.Connection.GetProcessId(endPoint)); }
protected SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint, CancellationTokenSource cancellationTokenSource, Request?request) : this(server) { CancellationTokenSource = cancellationTokenSource; ProxyClient = new ProxyClient(); HttpClient = new HttpWebClient(request); LocalEndPoint = endPoint; EnableWinAuth = server.EnableWinAuth && isWindowsAuthenticationSupported; HttpClient.ProcessId = new Lazy <int>(() => ProxyClient.Connection.GetProcessId(endPoint)); }
/// <summary> /// Constructor to initialize the proxy /// </summary> internal SessionEventArgs() { Client = new ProxyClient(); ProxySession = new HttpWebSession(); }