A minimal proxy auto config file generator based on ip range.
A minimal proxy auto config file generator based on ip range.
Why?
Because with my new patch to shadowsocks-libev, the embedded bypass function in ss-local is working correctly now.
This bypass function supports regex and ip range, read the example
A PAC(Proxy auto-config) file generator working with fetched China IP range, which helps walk around GFW.
Mono generates a much smaller and faster PAC file than any other project does.
This PAC file is designed to be hosted on your Openwrt routers for your mobile device, which means the size and the efficiency have the highest priority. When it's hosted on your VPS with gzip or used on your computer, we don't care that things.
The minimal unit of the APNIC's IP allocation is 256, which means it's safe to do IP >> 8 on IP range data. If you use data from some otherthings, modify my codes first.
$ git clone https://github.com/blackgear/mono_pac.git…ONLY Python 2 is supported.
-os option reduce 45% file size with 2.8% extra efficiency loss, but it may cause some PAC management extensions like SwitchOmega crash.
-op option provide best performance and compatibility but larger PAC file.
If neither -os nor -op option is added, the normal mode with give your a balance result.
When you browse https://www.google.com/abc, The Pac works in this way:
+-----------------------+
| Grab Host: |
| Host=www.google.com |
+-----------------------+
|
v
+-----------------------+
| Domain=www.google.com |
| Domain=google.com | 17346).
JS file is pre-compressed by uglifyjs2 with this arguments:
uglifyjs -c -m toplevel -r 'FindProxyForURL' -- mono.js > mono.min.js uglifyjs -c -m toplevel -r 'FindProxyForURL' -- mono-perf.js > mono-perf.min.js uglifyjs -c -m toplevel -r 'FindProxyForURL' -- mono-size.js > mono-size.min.js
## Trivia
The PAC instance will be reuse instead of start new instance for every request. The code in the root scope of the PAC file will be run only once. The code in the FindProxyForURL function's scope will be run each time you browser the internet.
Just test this two PAC files:
var unixtime_ms = new Date().getTime();
while(new Date().getTime() < unixtime_ms + 5000) {}
function FindProxyForURL(url, host) {
return "DIRECT;";
}
function FindProxyForURL(url, host) {
var unixtime_ms = new Date().getTime();
while(new Date().getTime() < unixtime_ms + 5000) {}
return "DIRECT;";
}
So put all definations in the root scope will accelerate the PAC file.
## LICENSE
The MIT License
Copyright (c) 2015 Daniel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.No open issues yet, or sync has not completed.