Skip to content

Commit 48c28cc

Browse files
committed
5.5.6 update smart route policy and fix connection block issue.
1 parent d9f8aca commit 48c28cc

6 files changed

Lines changed: 16 additions & 5 deletions

File tree

code/default/lib/noarch/front_base/connect_manager.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def __init__(self, logger, config, connect_creator, ip_manager, check_local_netw
156156

157157
self.thread_num_lock = threading.Lock()
158158
self.timeout = 4
159+
self.start_connect_time = 0
159160
self.thread_num = 0
160161
self.running = True
161162

@@ -233,6 +234,12 @@ def _create_more_connection(self):
233234
self.connecting_more_thread.start()
234235

235236
def _create_more_connection_worker(self):
237+
if self.start_connect_time and self.start_connect_time + 30 < time.time():
238+
self.start_connect_time = 0
239+
self.config.https_max_connect_thread += 1
240+
self.logger.warning("Connect creating process blocked, max connect thread increase to %d",
241+
self.config.https_max_connect_thread)
242+
236243
while self.thread_num < self.config.https_max_connect_thread and self._need_more_ip():
237244

238245
self.thread_num_lock.acquire()
@@ -254,7 +261,9 @@ def _connect_thread(self, sleep_time=0):
254261
if self.new_conn_pool.qsize() > self.config.https_connection_pool_max:
255262
break
256263

264+
self.start_connect_time = time.time()
257265
self._connect_process()
266+
self.start_connect_time = 0
258267
finally:
259268
self.thread_num_lock.acquire()
260269
self.thread_num -= 1

code/default/smart_router/local/gfw_black_list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,7 @@ googleplus.com
19071907
googlescholar.com
19081908
googlesile.com
19091909
googlesource.com
1910+
googlesyndication.com
19101911
googletagservices.com
19111912
googleusercontent.com
19121913
googlevideo.com

code/default/smart_router/local/ip_region.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def check_ip(self, ip):
8989
return lo & 1
9090

9191
def check_ips(self, ips):
92+
# return True if any ip in China
9293
ips = utils.to_str(ips)
9394
for ip in ips:
9495
try:

code/default/smart_router/local/smart_route.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def handle_domain_proxy(sock, host, port, client_address, left_buf=""):
562562
#ips = g.dns_query.query(host)
563563
#if check_local_network.IPv6.is_ok() and have_ipv6(ips) and port == 443:
564564
# rule_list = ["direct", "gae", "socks", "redirect_https"]
565-
# gae is more faster then direct.
565+
# gae is fast then direct.
566566

567567
rule = g.domain_cache.get_rule(host)
568568
if rule != "unknown":
@@ -586,9 +586,9 @@ def handle_domain_proxy(sock, host, port, client_address, left_buf=""):
586586
else:
587587
ips = g.dns_query.query_recursively(host, 1)
588588
if g.ip_region.check_ips(ips):
589-
rule_list = ["direct", "socks", "redirect_https"]
589+
rule_list = ["direct", "redirect_https", "socks", "gae"]
590590
else:
591-
rule_list = ["direct", "gae", "socks", "redirect_https"]
591+
rule_list = ["gae", "socks", "direct", "redirect_https"]
592592
else:
593593
rule_list = ["direct", "socks", "gae", "redirect_https"]
594594

code/default/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.5.5
1+
5.5.6

code/default/x_tunnel/local/base_container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ def send_to_sock(self, data):
694694
try:
695695
sended = sock.send(buf[start:start + send_size])
696696
except Exception as e:
697-
self.xlog.info("%s conn:%d send closed", self.session.session_id, self.conn_id)
697+
self.xlog.info("%s conn:%d send closed: %r", self.session.session_id, self.conn_id, e)
698698
sock.close()
699699
self.sock = None
700700
if self.is_client:

0 commit comments

Comments
 (0)