source: apps/proxyscript/i2pProxy.pac @ cbe12ad

Last change on this file since cbe12ad was cbe12ad, checked in by zzz <zzz@…>, 17 years ago

cervantes' web browser auto-proxy script

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*******************************************************
2** Proxy Auto Configure Script with I2P Host Detection.
3**
4** Author:  Cervantes
5** License: Public Domain
6** Date:    11 May 2004
7**
8** Revised: 17 May 2004
9** Added:
10**       Ability for the user to control the proxy
11**       status on a per browser-session basis.
12********************************************************/
13
14/* C O N F I G U R A T I O N
15*/
16
17/* Replace normal with "PROXY yourproxy:port" if you run
18** behind a Proxy Server by default.
19*/
20var normal = "DIRECT";
21
22/* Specify the I2P proxy connection details here.
23*/
24
25var i2pProxy = "PROXY 127.0.0.1:4444";
26
27/*   Set the default status of proxy detection here:
28**
29**
30**   [1] "auto" => Proxy will be used automatically if
31**                 '->  an ".i2p" url is detected.
32**                 '->  You will only be anonymous for ".i2p" domains.
33**
34**   [2] "on"   => Proxy is enabled all the time. (safest)
35**                 '->  NB. Normal web available only via
36**                 '->  i2p outproxies.
37**                 '->  You can be fairly confident of anonymity.
38**
39**   [3] "off"  => Completely Bypass the proxy and therefore i2p.
40**                 '->  no i2p sites will be accessible...
41**                 '->  ...your browsing habits can potentially
42**                 '->  be traced back to you!
43**
44*/
45
46var proxyStatus = "auto";
47
48/*   By setting statusKeyword to "all" you can set these options at runtime
49**   for the duration of the browser session by entering special commands
50**   into your browser address bar.
51**   
52**   Due to limitations in the way proxy scripting works, a malicious site
53**   could change your status mode by linking to command keywords...
54**   eg. <img src="i2p.off" ...
55**   This is why the default setting for statusKeyword is "limited", which only
56**   allows you to set the proxy status to "on".
57**
58**   [1] "all"  => All proxy status urls are available.
59**               '->  i2p.on, i2p.off, i2p.auto (respective to proxyStatus settings)
60**               '->  WARNING: Setting "all" is a big risk to your anonymity!
61**               
62**   [2] "limited"  => Only i2p.on is available..
63**                      '->  This setting lasts for the duration of the browser setting.
64**                      '->  You have to close your browser in order to revert to
65**                      '->  your default proxyStatus configuration.
66**
67**   [3] "off"  => No command urls available.
68**               '->  The status mode can only be altered by editing the above
69**               '->  proxyStatus setting. (safest)
70**
71*/
72
73var statusKeyword = "limited";
74
75/*
76**   By default if proxyStatus is set to "auto" the config script
77**   will fall back to your normal connection settings if the
78**   i2p proxy is offline. This is handy for browsing your locally
79**   hosted eepsites when your router is not running (for instance).
80**   However this can mean that requests to external eepsites could
81**   be forwarded to the outweb and potentially compromise some of
82**   your rights to anonymity.
83**   Setting "true" here enables strict mode where all requests to ".i2p"
84**   sites will be rejected if the i2p proxy is offline. (safest)
85*/
86
87var strict = false;
88
89
90/* E N D   C O N F I G U R A T I O N
91*/
92
93
94/* Allows the proxy to fallback on "normal" settings
95** '-> if the i2p router is offline.
96*/
97
98if (strict == false) {
99        i2pProxy = i2pProxy + "; " + normal;
100}
101
102/* This function gets called every time a url is submitted
103*/
104
105function FindProxyForURL(url, host) {
106    /* checks for a special command url that
107    ** '-> changes the status of the proxy script.
108    */
109
110   if (statusKeyword != "off") {
111      if (host == "i2p.off" && statusKeyword == "all") {
112         /*Proxy is bypassed - outweb available only
113         */
114         proxyStatus = "off";
115      } else if (host == "i2p.auto" && statusKeyword == "all") {
116          /* Proxy is used only for .i2p hosts otherwise
117          ** '-> browse as normal.
118          */
119          proxyStatus = "auto";
120      } else if (host == "i2p.on" && statusKeyword == "limited") {
121          /* Only I2P traffic is accepted.
122          */
123          proxyStatus = "on";
124      }
125   }
126
127   if (proxyStatus == "off") {
128       /* Proxy is completely bypassed.
129       */
130       return normal;
131   } else if (proxyStatus == "on") {
132       /* All requests are forward to the proxy.
133       */
134       return i2pProxy;
135   }
136   
137   host = host.toLowerCase();
138   /* check tld for "i2p" - if found then redirect
139   ** '-> request to the i2p proxy
140   */
141   
142   if (shExpMatch(host, "*.i2p")) {    // seems more reliable than:
143       return i2pProxy;                     // dnsDomainIs(host, ".i2p") ||
144   } else {                                      // i2pRegex.test(host)
145       return normal;
146   }
147}
Note: See TracBrowser for help on using the repository browser.