@@ -37,52 +37,33 @@ Setup HTTP proxy:
37
37
ProxyServer .BeforeRequest += OnRequest ;
38
38
ProxyServer .BeforeResponse += OnResponse ;
39
39
40
- // Exclude Https addresses you don't want to proxy
41
- // Usefull for clients that use certificate pinning
42
- // for example dropbox.com
43
40
var explicitEndPoint = new ExplicitProxyEndPoint (IPAddress .Any , 8000 , true ){
41
+ // Exclude Https addresses you don't want to proxy/cannot be proxied
42
+ // for example exclude dropbox client which use certificate pinning
44
43
ExcludedHttpsHostNameRegex = new List <string >() { " dropbox.com" }
45
44
};
46
45
47
- // An explicit endpoint is where the client knows about the existance of a proxy
48
- // So client sends request in a proxy friendly manner
46
+ // Add an explicit endpoint where the client is aware of the proxy
47
+ // So client would send request in a proxy friendly manner
49
48
ProxyServer .AddEndPoint (explicitEndPoint );
50
49
ProxyServer .Start ();
51
-
52
-
53
- // Transparent endpoint is usefull for reverse proxying (client is not aware of the existance of proxy)
54
- // A transparent endpoint usually requires a network router port forwarding HTTP(S) packets to this endpoint
55
- // Currently do not support Server Name Indication (It is not currently supported by SslStream class)
56
- // That means that the transparent endpoint will always provide the same Generic Certificate to all HTTPS requests
57
- // In this example only google.com will work for HTTPS requests
58
- // Other sites will receive a certificate mismatch warning on browser
59
- // Please read about it before asking questions!
60
- var transparentEndPoint = new TransparentProxyEndPoint (IPAddress .Any , 8001 , true ) {
61
- GenericCertificateName = " google.com"
62
- };
63
- ProxyServer .AddEndPoint (transparentEndPoint );
64
-
65
-
50
+
51
+ // Only explicit proxies can be set as a system proxy!
52
+ ProxyServer .SetAsSystemHttpProxy (explicitEndPoint );
53
+ ProxyServer .SetAsSystemHttpsProxy (explicitEndPoint );
54
+
66
55
foreach (var endPoint in ProxyServer .ProxyEndPoints )
67
56
Console .WriteLine (" Listening on '{0}' endpoint at Ip {1} and port: {2} " ,
68
57
endPoint .GetType ().Name , endPoint .IpAddress , endPoint .Port );
69
58
70
- // You can also add/remove end points after proxy has been started
71
- ProxyServer .RemoveEndPoint (transparentEndPoint );
72
-
73
- // Only explicit proxies can be set as system proxy!
74
- ProxyServer .SetAsSystemHttpProxy (explicitEndPoint );
75
- ProxyServer .SetAsSystemHttpsProxy (explicitEndPoint );
76
-
77
59
// wait here (You can use something else as a wait function, I am using this as a demo)
78
60
Console .Read ();
79
61
80
62
// Unsubscribe & Quit
81
63
ProxyServer .BeforeRequest -= OnRequest ;
82
- ProxyServer .BeforeResponse -= OnResponse ;
64
+ ProxyServer .BeforeResponse -= OnResponse ;
83
65
ProxyServer .Stop ();
84
66
85
-
86
67
```
87
68
Sample request and response event handlers
88
69
0 commit comments