source: apps/proxyscript/i2pProxy.pac @ eae86f5

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

Updates by cervantes:

  • Property mode set to 100644
File size: 6.2 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: 07 Sep 2004
9** Changes:
10**       Proxy recursion disabled by default (strict)
11**       Password Authentication for session commands
12**       Support for http://path?i2paddresshelper=BASE64
13**       Support for http://i2p/BASE64/path syntax
14** Revised: 17 May 2004
15** Changes:
16**       Ability for the user to control the proxy
17**       status on a per browser-session basis.
18********************************************************/
19
20
21/* C O N F I G U R A T I O N
22*/
23
24/* Replace normal with "PROXY yourproxy:port" if you run
25** behind a Proxy Server by default.
26*/
27var normal = "DIRECT";
28
29/* Specify the I2P proxy connection details here.
30*/
31
32var i2pProxy = "PROXY 127.0.0.1:4444";
33
34/*   Set the default status of proxy detection here:
35**
36**
37**   [1] "auto" => Proxy will be used automatically if
38**                 '->  an ".i2p" url is detected.
39**                 '->  You will only be anonymous for ".i2p" domains.
40**
41**   [2] "on"   => Proxy is enabled all the time. (safest)
42**                 '->  NB. Normal web available only via
43**                 '->  i2p outproxies.
44**                 '->  You can be fairly confident of anonymity.
45**
46**   [3] "off"  => Completely Bypass the proxy and therefore i2p.
47**                 '->  no i2p sites will be accessible...
48**                 '->  ...your browsing habits can potentially
49**                 '->  be traced back to you!
50**
51*/
52
53var proxyStatus = "auto";
54
55/*   By setting statusKeyword to "all" you can set these options at runtime
56**   for the duration of the browser session by entering special commands
57**   into your browser address bar.
58**   
59**   Due to limitations in the way proxy scripting works, a malicious site
60**   could change your status mode by linking to command keywords...
61**   eg. <img src="i2p.off" ...
62**   This is why the default setting for statusKeyword is "limited", which only
63**   allows you to set the proxy status to "on". See also keywordAuthPassword.
64**
65**   [1] "all"  => All proxy status urls are available.
66**               '->  i2p.on, i2p.off, i2p.auto (respective to proxyStatus settings)
67**               '->  WARNING: Setting "all" is a big risk to your anonymity!
68**               '->  In this mode it is highly recommended you set an AuthPassword too!
69**
70**   [2] "limited"  => Only i2p.on is available..
71**                      '->  This setting lasts for the duration of the browser setting.
72**                      '->  You have to close your browser in order to revert to
73**                      '->  your default proxyStatus configuration.
74**
75**   [3] "off"  => No command urls available.
76**               '->  The status mode can only be altered by editing the above
77**               '->  proxyStatus setting. (safest)
78**
79*/
80
81var statusKeyword = "all";
82
83/*
84**   By default if proxyStatus is set to "auto" the config script
85**   will fall back to your normal connection settings if the
86**   i2p proxy is offline. This is handy for browsing your locally
87**   hosted eepsites when your router is not running (for instance).
88**   However this can mean that requests to external eepsites could
89**   be forwarded to the outweb and potentially compromise some of
90**   your rights to anonymity.
91**   Setting "true" here enables strict mode where all requests to ".i2p"
92**   sites will be rejected if the i2p proxy is offline. (safest)
93*/
94
95var strict = true;
96
97/*
98**   By setting an authentication password, all activated session keywords
99**   will require the addition of a password to prevent malicious sites from
100**   hijacking your proxy settings. ie. <img src="i2p.off" ...
101**   Users should append whatever they set here to any command keywords
102**   they use.
103**   eg. i2p.on.passw0rd
104**   If left blank, authentication is ignored - it is recommended that
105**   you use "limited" statusKeyword mode if you choose not to require a password.
106**   If you do require this feature then you should replace the default "passw0rd" with
107**   one of your own (recommend at least 8 letters with a case-sensitive alpha-numeric
108**   mix of characters).
109**
110*/
111
112var keywordAuthPassword = "passw0rd";
113
114
115/* E N D   C O N F I G U R A T I O N
116*/
117
118
119/* Allows the proxy to fallback on "normal" settings
120** '-> if the i2p router is offline.
121*/
122
123if (strict == false) {
124     i2pProxy = i2pProxy + "; " + normal;
125}
126
127/*Check for User Authentication Password.
128*/
129if (keywordAuthPassword != "") {
130     keywordAuthPassword = "." + keywordAuthPassword;
131}
132
133/* This function gets called every time a url is submitted
134*/
135
136function FindProxyForURL(url, host) {
137    /* checks for a special command url that
138    ** '-> changes the status of the proxy script.
139    */
140
141   if (statusKeyword != "off") {
142      if (host == "i2p.off" + keywordAuthPassword && statusKeyword == "all") {
143         /*Proxy is bypassed - outweb available only
144         */
145         proxyStatus = "off";
146      } else if (host == "i2p.auto" + keywordAuthPassword && statusKeyword == "all") {
147          /* Proxy is used only for .i2p hosts otherwise
148          ** '-> browse as normal.
149          */
150          proxyStatus = "auto";
151      } else if (host == "i2p.on" + keywordAuthPassword && (statusKeyword == "limited" ||
152                                                            statusKeyword == "all"        )) {
153          /* Only I2P traffic is accepted.
154          */
155          proxyStatus = "on";
156      }
157   }
158
159   if (proxyStatus == "off") {
160       /* Proxy is completely bypassed.
161       */
162       return normal;
163   } else if (proxyStatus == "on") {
164       /* All requests are forward to the proxy.
165       */
166       return i2pProxy;
167   }
168   
169   host = host.toLowerCase();
170   /* check tld for "i2p" or oOo's new "i2paddresshelper" syntax - if found then redirect
171   ** '-> request to the i2p proxy
172   */
173   
174   if (url.match(/^http:\/\/i2p\/[a-zA-Z0-9\-\~]{516}|i2paddresshelper=/i) ||
175       shExpMatch(host, "*.i2p")) {                       // seems more reliable than:
176       return i2pProxy;                                     // dnsDomainIs(host, ".i2p") ||
177   } else {                                                   // i2pRegex.test(host)
178       return normal;
179   }
180}
Note: See TracBrowser for help on using the repository browser.