Skip to content

Commit

Permalink
Merge pull request XX-net#1 from XX-net/master
Browse files Browse the repository at this point in the history
合并到最新版本
  • Loading branch information
Cat7373 committed May 7, 2015
2 parents 1ca36dc + 3c07068 commit 2cc9ada
Show file tree
Hide file tree
Showing 18 changed files with 3,319 additions and 3,074 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
XX-Net
========
项目状态:目前在某些地区、网络下无法翻墙,如果使用有问题,请反馈具体地区和网络接入商
项目状态:目前可用性恢复正常,刚下载可能需要跑一个晚上不关闭,系统会找到好用的ip,使用起来才更流畅


下载链接:
==========
测试版:
https://codeload.github.com/XX-net/XX-Net/zip/1.13.5
https://codeload.github.com/XX-net/XX-Net/zip/1.14.1

稳定版:
https://codeload.github.com/XX-net/XX-Net/zip/1.12.5
https://codeload.github.com/XX-net/XX-Net/zip/1.13.6

(1.8.3之前的用户,请重新部署服务端)
(1.13.6 之前的用户,请重新部署服务端)


版本https://github.com/XX-net/XX-Net/releases
版本历史和说明https://github.com/XX-net/XX-Net/releases



Expand Down
2 changes: 1 addition & 1 deletion goagent/3.1.49/local/check_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def test_keepalive(ip_str, interval=5):
# therefor, different host need new ssl connection.

def test_server_type(ssl_sock, ip):
request_data = "GET / HTTP/1.1\r\nAccept: */*\r\nHost: %s\r\nConnection: Keep-Alive\r\n\r\n" % ip
request_data = "HEAD / HTTP/1.1\r\nAccept: */*\r\nHost: %s\r\n\r\n" % ip
time_start = time.time()
ssl_sock.send(request_data.encode())
response = httplib.HTTPResponse(ssl_sock, buffering=True)
Expand Down
10 changes: 4 additions & 6 deletions goagent/3.1.49/local/connect_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,12 @@ def keep_alive_thread(self):
while self.keep_alive:
time.sleep(2)
try:
sock_list = self.gae_conn_pool.get_need_keep_alive(maxtime=200)
sock_list = self.new_conn_pool.get_need_keep_alive(maxtime=230)
for ssl_sock in sock_list:
ssl_sock.close()

sock_list = self.gae_conn_pool.get_need_keep_alive(maxtime=200)
for ssl_sock in sock_list:
# only keep little alive link.
# if you have 25 appid, you can keep 5 alive link.
if self.gae_conn_pool.qsize() > max(1, len(appid_manager.working_appid_list)/2):
Expand Down Expand Up @@ -511,11 +514,6 @@ def _create_connection(ip_port, delay=0):
# record TCP connection time
conn_time = time.time() - start_time
logging.debug("tcp conn %s time:%d", ip, conn_time * 1000)
if conn_time * 1000 < 400:
google_ip.report_bad_ip(ip)
logging.warn("ip:%s conn_time:%d", ip, conn_time * 1000)
sock.close()
return

google_ip.update_ip(ip, conn_time * 2000)
#logging.info("create_tcp update ip:%s time:%d", ip, conn_time * 2000)
Expand Down
51 changes: 33 additions & 18 deletions goagent/3.1.49/local/direct_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def fetch(method, host, path, headers, payload, bufsize=8192):
response.begin()
ssl_sock.settimeout(orig_timeout)
except httplib.BadStatusLine as e:
logging.warn("_request bad status line:%r", e)
logging.warn("direct_handler.fetch bad status line:%r", e)
response = None
except Exception as e:
logging.warn("_request:%r", e)
logging.warn("direct_handler.fetch:%r", e)
return response


Expand All @@ -90,18 +90,25 @@ def handler(method, host, url, headers, body, wfile):
response = fetch(method, host, url, headers, body)
if response:
break

except OpenSSL.SysCallError as e:
errors.append(e)
logging.warn("direct_handler.handler err:%r %s/%s", e, host, url)
except Exception as e:
errors.append(e)
logging.exception('direct_handler.handler %r %s %s , retry...', e, host, url)

try:
wfile.write("HTTP/1.1 %d %s\r\n" % (response.status, response.reason))
response_headers = dict((k.title(), v) for k, v in response.getheaders())
for key, value in response.getheaders():
send_header(wfile, key, value)
#logging.debug("Head- %s: %s", key, value)
wfile.write("\r\n")
send_to_broswer = True
try:
wfile.write("HTTP/1.1 %d %s\r\n" % (response.status, response.reason))
response_headers = dict((k.title(), v) for k, v in response.getheaders())
for key, value in response.getheaders():
send_header(wfile, key, value)
#logging.debug("Head- %s: %s", key, value)
wfile.write("\r\n")
except Exception as e:
send_to_broswer = False
logging.warn("direct_handler.handler send response fail. t:%d e:%r %s/%s", time.time()-time_request, e, host, url)

if method == 'HEAD' or response.status in (204, 304):
logging.info("DIRECT t:%d %d %s %s", (time.time()-time_request)*1000, response.status, host, url)
Expand All @@ -117,13 +124,22 @@ def handler(method, host, url, headers, body, wfile):
except httplib.IncompleteRead, e:
data = e.partial

if not data:
wfile.write('0\r\n\r\n')
break
length += len(data)
wfile.write('%x\r\n' % len(data))
wfile.write(data)
wfile.write('\r\n')
if send_to_broswer:
try:
if not data:
wfile.write('0\r\n\r\n')
break
length += len(data)
wfile.write('%x\r\n' % len(data))
wfile.write(data)
wfile.write('\r\n')
except Exception as e:
send_to_broswer = False
logging.warn("direct_handler.handler send Transfer-Encoding t:%d e:%r %s/%s", time.time()-time_request, e, host, url)
else:
if not data:
break

response.close()
logging.info("DIRECT chucked t:%d s:%d %d %s %s", (time.time()-time_request)*1000, length, response.status, host, url)
return
Expand All @@ -136,7 +152,6 @@ def handler(method, host, url, headers, body, wfile):
start, end, length = 0, content_length-1, content_length

time_start = time.time()
send_to_broswer = True
while True:
data = response.read(config.AUTORANGE_BUFSIZE)
if not data and time.time() - time_start > 120:
Expand Down Expand Up @@ -168,7 +183,7 @@ def handler(method, host, url, headers, body, wfile):
time_except = time.time()
time_cost = time_except - time_request
if e[0] in (errno.ECONNABORTED, errno.EPIPE) or 'bad write retry' in repr(e):
logging.warn("direct_handler err:%r %s %s time:%d", e, host, url, time_cost)
logging.exception("direct_handler err:%r %s %s time:%d", e, host, url, time_cost)
else:
logging.exception("direct_handler except:%r %s %s", e, host, url)
except Exception as e:
Expand Down
6 changes: 4 additions & 2 deletions goagent/3.1.49/local/gae_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def wrap(*args, **kwargs):
def send_header(wfile, keyword, value):
keyword = keyword.title()
if keyword == 'Set-Cookie':
# https://cloud.google.com/appengine/docs/python/urlfetch/responseobjects
for cookie in re.split(r', (?=[^ =]+(?:=|$))', value):
wfile.write("%s: %s\r\n" % (keyword, cookie))
#logging.debug("Head1 %s: %s", keyword, cookie)
Expand Down Expand Up @@ -285,7 +286,7 @@ def handler(method, url, headers, body, wfile):
try:
response = fetch(method, url, headers, body)
if response.app_status != 200:
logging.debug("fetch gae status:%s url:%s", response.app_status, url)
logging.warn("fetch gae status:%s url:%s", response.app_status, url)


if response.app_status == 404:
Expand Down Expand Up @@ -373,9 +374,10 @@ def handler(method, url, headers, body, wfile):
else:
start, end, length = 0, content_length-1, content_length

time_start = time.time()

send_to_broswer = True
while True:
time_start = time.time()
data = response.read(config.AUTORANGE_BUFSIZE)
if not data and time.time() - time_start > 20:
response.close()
Expand Down
Loading

0 comments on commit 2cc9ada

Please sign in to comment.