wallproxy配置
gaehost_http = 'www.google.cn|www.google.com.hk'
gaehost_https = 'www.google.com.hk'
https = False
pac = False
onlyone = '***.com'
usephp = '****.com'
usego = '*****.com'
gae_extra_option = {
#'range0': 100000,
#'range': 500000,
#'max_threads': 10,
#'headers': 'Content-Type: application/octet-stream',
#'proxy': '',
}
if appid:
if isinstance(crypto, basestring): crypto += '|'*20
if isinstance(password, basestring): password += ('|'+password)*20
app = zip(*(app.split('|') if isinstance(app, basestring) else app
for app in (appid, crypto, password)))
gaeproxy = []; https = 'https' if https else 'http'
for appid,crypto,password in app:
appid = {'url': '%s://%s.appspot.com/%s.py' % (https, appid, server_type)}
if crypto: appid['crypto'] = crypto
appid['key'] = password
gaeproxy.append(appid)
gaeproxy[0].update(gae_extra_option)
gaeproxy[0].setdefault('proxy', '')
del plugins['plugins.gaeproxy'], app
plugins['plugins.'+server_type] = 'gaeproxy'
if 'gaehost_http' in vars() and isinstance(gaehost_http, basestring):
gaehost_http = gaehost_http and gaehost_http.split('|') or None
if 'gaehost_https' in vars() and isinstance(gaehost_https, basestring):
gaehost_https = gaehost_https and gaehost_https.split('|') or None
if isinstance(onlyone, basestring):
onlyone = onlyone and onlyone.split('|') or []
if isinstance(usephp, basestring):
usephp = usephp and usephp.split('|') or []
if isinstance(usego, basestring):
usego = usego and usego.split('|') or []
def find_http_handler(method, url, headers):
if len(gaeproxy)>1 and onlyone:
for host in onlyone:
if dnsDomainIs(url.hostname, host): return gaeproxy[0]
if len(forold)>0 and usephp:
for host in usephp:
if dnsDomainIs(url.hostname, host): return forold
if len(goagent)>0 and usego:
for host in usego:
if dnsDomainIs(url.hostname, host): return goagent
return gaeproxy
if not pac: del plugins['plugins.autoproxy']
del (server_type, appid, password, crypto, https, pac, gae_extra_option)
#find_http_handler = print_result(find_http_handler, lambda r,m,u,h:'%s %s'%(u.geturl(),r))
#find_http_handler = print_result(find_http_handler)