@@ -19,21 +19,31 @@ public void StartProxy()
19
19
//Exclude Https addresses you don't want to proxy
20
20
//Usefull for clients that use certificate pinning
21
21
//for example dropbox.com
22
- var explicitEndPoint = new ExplicitProxyEndPoint ( IPAddress . Loopback , 8000 , true ) {
22
+ var explicitEndPoint = new ExplicitProxyEndPoint ( IPAddress . Any , 8000 , true ) {
23
23
ExcludedHttpsHostNameRegex = new List < string > ( ) { "dropbox.com" }
24
24
} ;
25
25
26
- var transparentEndPoint = new TransparentProxyEndPoint ( IPAddress . Loopback , 8001 , true ) ;
27
-
26
+ //An explicit endpoint is where the client knows about the exististance of a proxy
27
+ //So client sends request in a proxy friendly manner
28
28
ProxyServer . AddEndPoint ( explicitEndPoint ) ;
29
29
ProxyServer . Start ( ) ;
30
-
30
+
31
31
//You can also add/remove end points after proxy has been started
32
+ //Transparent endpoint is usefull for reverse proxying (client is not aware of the existance of proxy)
33
+ //A transparent endpoint usually requires a network router port forwarding HTTP(S) packets to this endpoint
34
+ //Currently do not support Server Name Indication (It is not currently supported by SslStream class)
35
+ //That means that the transparent endpoint will always provide the same Generic Certificate to all HTTPS requests
36
+ //In this example only google.com will work for HTTPS requests
37
+ //Other sites will receive a certificate mismatch warning on browser
38
+ //Please read about it before asking questions!
39
+ var transparentEndPoint = new TransparentProxyEndPoint ( IPAddress . Any , 8001 , true ) { GenericCertificateName = "google.com" } ;
32
40
ProxyServer . AddEndPoint ( transparentEndPoint ) ;
41
+ ProxyServer . RemoveEndPoint ( transparentEndPoint ) ;
33
42
34
43
foreach ( var endPoint in ProxyServer . ProxyEndPoints )
35
44
Console . WriteLine ( "Listening on '{0}' endpoint at Ip {1} and port: {2} " , endPoint . GetType ( ) . Name , endPoint . IpAddress , endPoint . Port ) ;
36
45
46
+ //Only explicit proxies can be set as system proxy!
37
47
ProxyServer . SetAsSystemHttpProxy ( explicitEndPoint ) ;
38
48
ProxyServer . SetAsSystemHttpsProxy ( explicitEndPoint ) ;
39
49
}
0 commit comments