Internet taught you Science Series IV:Pretty smart PAC!–Flora

I believe a lot of cheese have seen we write"You taught science Internet Series"We have been able to maneuver and handy inside and outside walls。But you have not found what I wrote there aSmart pacs things? This thing is flawed (At least I think so uh),You use this stuff comes fromautoproxy2pac,It is a precise record of the database by a wall site,Maintained by countless volunteers,Website collects experience of Internet users rely entirely on the wall,It is said that more than 3,000 sites containing,For such,But the wall is not all collected into websites or,When you're on niche sites when,It is still possible to hit the wall。Of course, this time you can also manually add,If you are using Firefox、Chrome, etc.,Adding not a problem,If you are using other browsers,It may be a bird tragedy。

So,Although it is not a stick and killed,But I do think is heavenly,So,Flora was born。If you often walk to a variety of small foreign server site,Perhaps it is your dish,It uses Python development,Can automatically grab IP data,Find out all domestic IP addresses,Generator allows browserAutomatically determine the IP address at home and abroadThe pac file,Agent to users is equivalent to VPN + chnroutes Experience over the wall。general speaking,Is that all foreign websites,Bypass;All domestic websites,Direct Connect。

Flora_Pac very simple to use,Compatible with a variety of platforms,So whether it is linux,Or lion,Or windows,All can。the following,They say to use it。

#!/usr/bin/env python
# Flora_Pac by @leaskh
# based on chnroutes project (by

import re
import urllib2
import argparse
import math

def generate_pac(proxy):
results = fetch_ip_data()
pacfile = ‘flora_pac.pac’
rfile = open(pacfile, ‘w’)
strLines = (
“// Flora_Pac by @leaskh”
“\nfunction FindProxyForURL(url, host)”
“\n var list = [”
intLines = 0
for ip,mask,_ in results:
if intLines > 0:
strLines = strLines + ‘,’
intLines = intLines + 1
strLines = strLines + “\n [‘%s’, ‘%s’]”%(ip, mask)
strLines = strLines + (
“\n ];”
“\n var ip = dnsResolve(host);”
“\n for (var i in list) {”
“\n if (isInNet(ip, list[i][0], list[i][1])) {”
“\n return ‘DIRECT’;”
“\n }”
“\n }”
“\n return ‘%s’;”
print (“Rules: %d items.n”
“Usage: Use the newly created %s as your web browser’s automatic ”
“proxy configuration (.pac) file.”%(intLines, pacfile))

def fetch_ip_data():
#fetch data from apnic
print “Fetching data from, it might take a few minutes, please wait…”
data = urllib2.urlopen(url).read()



for item in cndata:

imask = ^ 0xffffffff(num_ip-1)
#convert to string
mask[0]= imask[0:2]
mask[1]= imask[2:4]
mask[2]= imask[4:6]
mask[3]= imask[6:8]

#convert str to int
mask=[ int(i,16 ) for i in mask]
mask=”%d.% d.% d.% d”%tuple(mask)

#mask in *nix format


return results

if __name__==’__main__’:
parser=argparse.ArgumentParser(description=”Generate proxy auto-config rules.”)
parser.add_argument(‘-x’, ‘–proxy’,
default = ‘PROXY’,
nargs = '?’,
help = “Proxy Server, examples: ”
“SOCKS5; ”

args = parser.parse_args()


The above-cited section copy written down in a new text document,Save directly
Then run just fine,of course,If you are a windows user you may need to goDownload python runtimeWhat's XD
lion users may also need to download it,I forget what I've since been downloaded over anyway,So,I direct right click and select Open,thenpython launcherEnough。
After running,Next to this script generates a new pac,This is what we are going to use! Oh,Do not hurry,You have to set settings。Because we are using goagent,Does not match the default port and we use,But I have a pre-changing for the better。
If you still can not use,Please inform yourself open this pac text mode,However, the final


If you're too lazy to change, please download = = I just created it,Time is almost an article published date。
(This flora_pac.pac readily replace the pac before you use it。。。。。。)
(Also,From this pacHere,Also part of the content of the article also draws onHere。Thank them。)

Original article written by Gerber drop-off:R0uter's Blog » Internet taught you Science Series IV:Pretty smart PAC!–Flora

Reproduced Please keep the source and description link:

About the Author


The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。


Leave a Reply

Your email address will not be published. Required fields are marked *