private void SearchForProxyInspector() { var targetType = this.Target.GetType(); var inspectorBaseType = typeof(ProxyInspector <>).MakeGenericType(targetType); Assembly currentAssembly = Assembly.GetCallingAssembly(); // Flai.Unity.Editor assembly is always included var searchAssemblies = this.AssembliesToSearchForProxyInspectors.Concat(currentAssembly.AsEnumerable()); var matchingTypes = searchAssemblies.SelectMany( assembly => assembly.GetTypes().Where(type => inspectorBaseType.IsAssignableFrom(type) && typeof(IProxyInspector).IsAssignableFrom(type))); foreach (Type matchingType in matchingTypes) { if (!matchingType.ContainsGenericParameters && matchingType.GetConstructor(Type.EmptyTypes) != null) { var inspector = Activator.CreateInstance(matchingType) as IProxyInspector; if (inspector != null && this.AcceptProxyInspector(inspector)) { _proxyInspector = inspector; _hasSearchedForProxyInspector = true; return; } } } _hasSearchedForProxyInspector = true; }
public static ProxyEngine New(string harPath = null, bool autoStart = true, IProxyInspector proxyInspector = null) { var port = 8088; var ip = LocalIPAddress(); //the ip of the machine on which the proxy is running/listening return(new ProxyEngine(ip, port, autoStart, proxyInspector)); }
private ProxyEngine(IPAddress ipAddress, int port, bool autoStart = true, IProxyInspector proxyInspector = null) { _proxyInspector = proxyInspector; _listener = new ProxyListener(port, ipAddress, _proxyInspector); var uriBuilder = new UriBuilder("http", ipAddress.ToString(), port); Uri = uriBuilder.Uri; if (autoStart) _listener.Start(); }
private ProxyEngine(IPAddress ipAddress, int port, bool autoStart = true, IProxyInspector proxyInspector = null) { _proxyInspector = proxyInspector; _listener = new ProxyListener(port, ipAddress, _proxyInspector); var uriBuilder = new UriBuilder("http", ipAddress.ToString(), port); Uri = uriBuilder.Uri; if (autoStart) { _listener.Start(); } }
/// <summary> /// /// </summary> /// <param name="port"></param> /// <param name="ipAddress"></param> public ProxyListener(Int32 port, IPAddress ipAddress, IProxyInspector proxyInspector) { _proxyInspector = proxyInspector; try { _localAddress = ipAddress; _port = port; _proxySocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); } catch (Exception e) { throw new NotSupportedException("TcpListener not supported on this platform.", e); } }
public static ProxyRequest For(Socket clientSocket, IProxyInspector proxyInspector = null) { var request = new ProxyRequest { ClientSocket = clientSocket, ClientStream = new NetworkStream(clientSocket) }; if (proxyInspector != null) proxyInspector.OnRequestReceived(request); request.ResolvePid(); request.ReadPrologue(); return request; }
public static ProxyRequest For(Socket clientSocket, IProxyInspector proxyInspector = null) { var request = new ProxyRequest { ClientSocket = clientSocket, ClientStream = new NetworkStream(clientSocket) }; if (proxyInspector != null) { proxyInspector.OnRequestReceived(request); } request.ResolvePid(); request.ReadPrologue(); return(request); }
protected virtual bool AcceptProxyInspector(IProxyInspector inspector) { return(true); }
public static ProxyEngine New(string harPath = null, bool autoStart = true, IProxyInspector proxyInspector = null) { var port = 8088; var ip = LocalIPAddress(); //the ip of the machine on which the proxy is running/listening return new ProxyEngine(ip, port, autoStart, proxyInspector); }