Skip to content

Commit

Permalink
fix ip sort issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-X-Net committed Jun 18, 2023
1 parent 04f8ee7 commit 28c9556
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
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 @@ -89,6 +89,7 @@ def set_default(self):
self.set_var("long_fail_threshold", 300)
self.set_var("long_fail_connect_interval", 180)
self.set_var("short_fail_connect_interval", 10)
self.set_var("shuffle_ip_on_first_load", 0)

# ip source
self.set_var("use_ipv6", "auto") #force_ipv4/force_ipv6
Expand Down
16 changes: 11 additions & 5 deletions code/default/lib/noarch/front_base/ip_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ def load_ip(self):
ip_str = str_l[0]
domain = str_l[1]
server = str_l[2]
handshake_time = int(str_l[3])
if file_path == self.default_ip_list_fn and self.config.shuffle_ip_on_first_load:
handshake_time = random.randint(500, 800)
else:
handshake_time = int(str_l[3])
if len(str_l) > 4:
fail_times = int(str_l[4])
else:
Expand All @@ -197,10 +200,13 @@ def load_ip(self):
self.logger.exception("load_ip line:%s err:%s", line, e)

self.logger.info("load ip_list %s num:%d, target num:%d", file_path, len(self.ip_dict), len(self.ip_list))
self.try_sort_ip(force=True)
# if file_path == self.default_good_ip_file:
# self.logger.info("first run, rescan all exist ip")
# self.start_scan_all_exist_ip()
if file_path == self.default_ip_list_fn and self.config.shuffle_ip_on_first_load:
self.logger.debug("first load, shuffle all ip")
random.shuffle(self.ip_list)
self.logger.debug("ip:%s",self.ip_list)
else:
self.try_sort_ip(force=True)

return

def save(self, force=False):
Expand Down
1 change: 1 addition & 0 deletions code/default/x_tunnel/local/cloudflare_front/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self, fn):
self.set_var("target_handshake_time", 500)
self.set_var("active_connect_interval", 3*60)
self.set_var("scan_ip_interval", 10)
self.set_var("shuffle_ip_on_first_load", 1)

# ip source
self.set_var("use_ipv6", "auto") # force_ipv4/force_ipv6/auto
Expand Down

0 comments on commit 28c9556

Please sign in to comment.