Skip to content

Commit

Permalink
6.9.23
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Jun 19, 2019
1 parent d43d130 commit 192c88a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 32 deletions.
44 changes: 14 additions & 30 deletions class/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def M(table):
sql = db.Sql()
return sql.table(table);

def HttpGet(url,timeout = 3,headers = {}):
def HttpGet(url,timeout = 6,headers = {}):
"""
发送GET请求
@url 被请求的URL地址(必需)
Expand Down Expand Up @@ -81,14 +81,22 @@ def http_get_home(url,timeout,ex):
res = HttpGet(new_url,timeout,headers)
if res:
writeFile("data/home_host.pl",host)
set_home_host(host)
return res
return ex
except: return ex

def httpGet(url,timeout=3):

def set_home_host(host):
ExecShell('sed -i "/www.bt.cn/d" /etc/hosts')
ExecShell("echo '' >> /etc/hosts")
ExecShell("echo '%s www.bt.cn' >> /etc/hosts" % host)
ExecShell('sed -i "/^\s*$/d" /etc/hosts')

def httpGet(url,timeout=6):
return HttpGet(url,timeout)

def HttpPost(url,data,timeout = 3,headers = {}):
def HttpPost(url,data,timeout = 6,headers = {}):
"""
发送POST请求
@url 被请求的URL地址(必需)
Expand Down Expand Up @@ -148,40 +156,16 @@ def http_post_home(url,data,timeout,ex):
res = HttpPost(new_url,data,timeout,headers)
if res:
writeFile("data/home_host.pl",host)
set_home_host(host)
return res
return ex
except: return ex

def httpPost(url,data,timeout=3):
def httpPost(url,data,timeout=6):
return HttpPost(url,data,timeout)

def check_home():
try:
if HttpGet('http://www.bt.cn/test.txt') == 'True': return True
hosts = '/etc/hosts'
hosts_body = ReadFile(hosts)
if hosts_body.find('www.bt.cn') != -1: return True

url = 'http://125.88.182.170/test.txt'
if sys.version_info[0] == 2:
import urllib2
req = urllib2.Request(url)
req.add_header('host','www.bt.cn')
result = urllib2.urlopen(req).read()
else:
import urllib.request
req = urllib.request.Request(url)
req.add_header('host','www.bt.cn')
result = urllib.request.urlopen(req).read()
result = result.decode('utf-8')
if result != 'True': return True
ExecShell("echo '' >> /etc/hosts")
ExecShell("echo '125.88.182.170 www.bt.cn' >> /etc/hosts")
return True
except:
return True


return True

def Md5(strings):
"""
Expand Down
2 changes: 1 addition & 1 deletion config/hosts.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ "103.224.251.67", "119.188.210.21", "45.32.116.160", "125.88.182.172"]
[ "103.224.251.67", "119.188.210.21", "45.32.116.160", "183.60.107.171" ]
2 changes: 1 addition & 1 deletion install/public.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export LANG=en_US.UTF-8
export LANGUAGE=en_US:en

get_node_url(){
nodes=(http://183.235.223.101:3389 http://125.88.182.172:5880 http://128.1.164.196 http://103.224.251.67 http://download.bt.cn);
nodes=(http://183.235.223.101:3389 http://119.188.210.21:5880 http://125.88.182.172:5880 http://103.224.251.67 http://download.bt.cn http://45.32.116.160 http://128.1.164.196);
i=1;
for node in ${nodes[@]};
do
Expand Down

0 comments on commit 192c88a

Please sign in to comment.