Skip to content

Commit

Permalink
release 5.1.1 fix issue and improve performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-X-Net committed Mar 29, 2023
1 parent 634ffe3 commit 8d69943
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@


### 最新公告:
2023-03-28
* 新版 5.1.0,内置ChatGPT
2023-03-29
* 新版 5.1.1, 提升速度、稳定性
* 5.1.0,内置ChatGPT
* 原来是4.x.x 的老版本,需要重新下载新版安装,不能应用内升级。


Expand Down
1 change: 1 addition & 0 deletions code/default/lib/noarch/front_base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def set_default(self):
self.set_var("dispather_max_workers", 60)
self.set_var("dispather_score_factor", 1)
self.set_var("dispather_max_idle_workers", 30)
self.set_var("dispather_worker_max_continue_fail", 2)

self.set_var("max_task_num", 100)

Expand Down
8 changes: 7 additions & 1 deletion code/default/lib/noarch/front_base/http_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def __init__(self, logger, ip_manager, config, ssl_sock, close_cb, retry_task_cb
self.accept_task = True
self.keep_running = True
self.processed_tasks = 0
self.continue_fail_tasks = 0
self.speed_history = []
self.last_recv_time = self.ssl_sock.create_time
self.last_send_time = self.ssl_sock.create_time
Expand Down Expand Up @@ -249,7 +250,12 @@ def get_host(self, task_host):
return self.ssl_sock.host

def is_life_end(self):
if time.time() > self.life_end_time:
now = time.time()
if now > self.life_end_time:
return True
elif now - self.last_recv_time > 230:
return True
elif self.continue_fail_tasks > self.config.dispather_worker_max_continue_fail:
return True
else:
return False
14 changes: 12 additions & 2 deletions code/default/lib/noarch/front_base/http_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,19 @@ def get_worker(self, nowait=False):
while self.running:
best_score = 99999999
best_worker = None
good_worker = 0
idle_num = 0
now = time.time()
for worker in self.workers:
if not worker.accept_task or worker.is_life_end():
if worker.is_life_end():
# self.logger.debug("not accept")
continue

good_worker += 1

if not worker.accept_task:
continue

if worker.version == "1.1":
idle_num += 1
else:
Expand All @@ -189,7 +195,7 @@ def get_worker(self, nowait=False):
best_score = score
best_worker = worker

if len(self.workers) < self.config.dispather_max_workers and \
if good_worker < self.config.dispather_max_workers and \
(best_worker is None or
idle_num < self.config.dispather_min_idle_workers or
len(self.workers) < self.config.dispather_min_workers or
Expand Down Expand Up @@ -268,11 +274,15 @@ def request(self, method, host, path, headers, body, url=b"", timeout=60):
if response and response.status == 200:
self.success_num += 1
self.continue_fail_num = 0
task.worker.continue_fail_tasks = 0
else:
self.logger.warn("task %s %s %s timeout", method, host, path)
self.fail_num += 1
self.continue_fail_num += 1
self.last_fail_time = time.time()
task.worker.continue_fail_tasks += 1
if task.worker.continue_fail_tasks > self.config.dispather_worker_max_continue_fail:
self.trigger_create_worker_cv.notify()

task.set_state("get_response")
return response
Expand Down
10 changes: 6 additions & 4 deletions code/default/smart_router/local/pipe_socks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ def add_socks(self, s1, s2):
with self.sock_notify:
s1.pair_sock = s2
s2.pair_sock = s1
self.select2.register(s1, selectors.EVENT_READ)
self.select2.register(s2, selectors.EVENT_READ)
self.read_set.add(s1)
self.read_set.add(s2)
# self.select2.register(s1, selectors.EVENT_READ)
# self.select2.register(s2, selectors.EVENT_READ)
# self.read_set.add(s1)
# self.read_set.add(s2)
self.try_add("READ", s1)
self.try_add("READ", s2)

self.sock_notify.notify()

Expand Down
2 changes: 1 addition & 1 deletion code/default/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.0
5.1.1
4 changes: 2 additions & 2 deletions code/default/x_tunnel/local/cloudflare_front/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, fn):
self.set_var("dispather_work_min_idle_time", 0)
self.set_var("dispather_work_max_score", 20000)
self.set_var("dispather_min_workers", 1)
self.set_var("dispather_max_workers", 3)
self.set_var("dispather_max_workers", 8)
self.set_var("dispather_score_factor", 1)

# http 2 worker
Expand All @@ -25,7 +25,7 @@ def __init__(self, fn):
self.set_var("ssl_first_use_timeout", 5)
self.set_var("connection_pool_min", 0)
self.set_var("https_new_connect_num", 0)
self.set_var("connect_create_interval", 3)
self.set_var("connect_create_interval", 2)

# check_ip
self.set_var("check_ip_subdomain", "scan1")
Expand Down

0 comments on commit 8d69943

Please sign in to comment.