Skip to content

Commit

Permalink
5.3.0 version, improve performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-X-Net committed Jul 8, 2023
1 parent 2455520 commit 760fd37
Show file tree
Hide file tree
Showing 40 changed files with 365 additions and 353 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@


### 最新公告:
2023-06-17
* 新版 5.2.0, 提升稳定性
2023-07-08
* 新版 5.3.0, 提升连接性能
* 5.1.0,内置ChatGPT
* 原来是4.x.x 的老版本,需要重新下载新版安装,不能应用内升级。

Expand Down
2 changes: 1 addition & 1 deletion code/default/gae_proxy/local/front.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def start(self):
self.ipv4_source, self.ipv6_source
)
self.ip_manager = IpManager(
logger, self.config, self.ip_source, check_local_network,
logger, self.config, self.ip_source, self.host_manager, check_local_network,
self.check_ip,
None,
os.path.join(module_data_path, "good_ip.txt"),
Expand Down
4 changes: 2 additions & 2 deletions code/default/launcher/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def _get_os_language():
else:
return None
except Exception as e:
xlog.exception("get lang except:%r", e)
return None
xlog.warn("get lang except:%r", e)
return "zh_CN"
elif sys_platform.platform == "ios":
lang_code = os.environ["IOS_LANG"]
if 'zh' in lang_code:
Expand Down
19 changes: 17 additions & 2 deletions code/default/launcher/module_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@


def start(module):
if not os.path.isdir(os.path.join(root_path, module)):
if module == "all":
modules = ["gae_proxy", "smart_router", "x_tunnel"]
for m in modules:
if not getattr(config,"enable_" + m):
continue

start(m)
return

elif not os.path.isdir(os.path.join(root_path, module)):
return

try:
Expand Down Expand Up @@ -69,7 +78,13 @@ def start(module):

def stop(module):
try:
if module not in proc_handler:
if module == "all":
modules = list(proc_handler)
for m in modules:
stop(m)
return

elif module not in proc_handler:
xlog.error("module %s not running", module)
return

Expand Down
10 changes: 8 additions & 2 deletions code/default/launcher/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,19 @@ def main():

allow_remote = 0
no_mess_system = 0
no_popup = 0
no_systray = 0
if len(sys.argv) > 1:
for s in sys.argv[1:]:
xlog.info("command args:%s", s)
if s == "-allow_remote":
allow_remote = 1
elif s == "-no_mess_system":
no_mess_system = 1
elif s == "-no_popup":
no_popup = 1
elif s == "-no_systray":
no_systray = 1

if allow_remote or config.allow_remote_connect:
xlog.info("start with allow remote connect.")
Expand All @@ -149,7 +155,7 @@ def main():
module_init.start_all_auto()
web_control.start(allow_remote)

if has_desktop and config.popup_webui == 1 and not restart_from_except:
if has_desktop and config.popup_webui == 1 and not restart_from_except and not no_popup:
host_port = config.control_port
import webbrowser
webbrowser.open("http://localhost:%s/" % host_port)
Expand All @@ -159,7 +165,7 @@ def main():
download_modules.start_download()
update_from_github.cleanup()

if config.show_systray:
if config.show_systray and not no_systray:
sys_platform.show_systray()
else:
while global_var.running:
Expand Down
84 changes: 43 additions & 41 deletions code/default/launcher/web_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def do_POST(self):
length = int(self.headers.get('Content-Length'))
content = self.rfile.read(length)
self.postvars = parse_qs(content, keep_blank_values=True)
self.postvars = self.unpack_reqs(self.postvars)
elif ctype == 'application/json':
length = int(self.headers.get('Content-Length'))
content = self.rfile.read(length)
Expand Down Expand Up @@ -346,9 +347,10 @@ def req_index_handler(self):
def req_config_handler(self):
req = urlparse(self.path).query
reqs = parse_qs(req, keep_blank_values=True)
reqs = self.unpack_reqs(reqs)
data = ''

if reqs['cmd'] == ['get_config']:
if reqs['cmd'] == 'get_config':

if module_init.xargs.get("allow_remote", 0):
allow_remote_connect = 1
Expand Down Expand Up @@ -376,10 +378,10 @@ def req_config_handler(self):
"postUpdateStat": config.postUpdateStat,
}
data = json.dumps(dat)
elif reqs['cmd'] == ['set_config']:
elif reqs['cmd'] == 'set_config':
if 'skip_version' in reqs:
skip_version = reqs['skip_version'][0]
skip_version_type = reqs['skip_version_type'][0]
skip_version = reqs['skip_version']
skip_version_type = reqs['skip_version_type']
if skip_version_type not in ["stable", "test"]:
data = '{"res":"fail"}'
else:
Expand All @@ -389,7 +391,7 @@ def req_config_handler(self):
update_from_github.update_info = ''
data = '{"res":"success"}'
elif 'check_update' in reqs:
check_update = reqs['check_update'][0]
check_update = reqs['check_update']
if check_update not in ["dont-check", "stable", "notice-stable", "test", "notice-test"]:
data = '{"res":"fail, check_update:%s"}' % check_update
else:
Expand All @@ -400,7 +402,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'language' in reqs:
language = reqs['language'][0]
language = reqs['language']

if language not in valid_language:
data = '{"res":"fail, language:%s"}' % language
Expand All @@ -413,7 +415,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'popup_webui' in reqs:
popup_webui = int(reqs['popup_webui'][0])
popup_webui = int(reqs['popup_webui'])
if popup_webui != 0 and popup_webui != 1:
data = '{"res":"fail, popup_webui:%s"}' % popup_webui
else:
Expand All @@ -422,7 +424,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'allow_remote_switch' in reqs:
allow_remote_switch = int(reqs['allow_remote_switch'][0])
allow_remote_switch = int(reqs['allow_remote_switch'])
if allow_remote_switch != 0 and allow_remote_switch != 1:
data = '{"res":"fail, allow_remote_connect:%s"}' % allow_remote_switch
else:
Expand Down Expand Up @@ -454,7 +456,7 @@ def req_config_handler(self):
xlog.debug("launcher web control restarted.")
data = '{"res":"success"}'
elif 'show_systray' in reqs:
show_systray = int(reqs['show_systray'][0])
show_systray = int(reqs['show_systray'])
if show_systray != 0 and show_systray != 1:
data = '{"res":"fail, show_systray:%s"}' % show_systray
else:
Expand All @@ -463,7 +465,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'show_android_notification' in reqs:
show_android_notification = int(reqs['show_android_notification'][0])
show_android_notification = int(reqs['show_android_notification'])
if show_android_notification != 0 and show_android_notification != 1:
data = '{"res":"fail, show_systray:%s"}' % show_android_notification
else:
Expand All @@ -472,7 +474,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'show_compat_suggest' in reqs:
show_compat_suggest = int(reqs['show_compat_suggest'][0])
show_compat_suggest = int(reqs['show_compat_suggest'])
if show_compat_suggest != 0 and show_compat_suggest != 1:
data = '{"res":"fail, show_compat_suggest:%s"}' % show_compat_suggest
else:
Expand All @@ -481,7 +483,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'no_mess_system' in reqs:
no_mess_system = int(reqs['no_mess_system'][0])
no_mess_system = int(reqs['no_mess_system'])
if no_mess_system != 0 and no_mess_system != 1:
data = '{"res":"fail, no_mess_system:%s"}' % no_mess_system
else:
Expand All @@ -490,7 +492,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'keep_old_ver_num' in reqs:
keep_old_ver_num = int(reqs['keep_old_ver_num'][0])
keep_old_ver_num = int(reqs['keep_old_ver_num'])
if keep_old_ver_num < 0 or keep_old_ver_num > 99:
data = '{"res":"fail, keep_old_ver_num:%s not in range 0 to 99"}' % keep_old_ver_num
else:
Expand All @@ -499,7 +501,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'auto_start' in reqs:
auto_start = int(reqs['auto_start'][0])
auto_start = int(reqs['auto_start'])
if auto_start != 0 and auto_start != 1:
data = '{"res":"fail, auto_start:%s"}' % auto_start
else:
Expand All @@ -513,7 +515,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'show_detail' in reqs:
show_detail = int(reqs['show_detail'][0])
show_detail = int(reqs['show_detail'])
if show_detail != 0 and show_detail != 1:
data = '{"res":"fail, show_detail:%s"}' % show_detail
else:
Expand All @@ -522,7 +524,7 @@ def req_config_handler(self):

data = '{"res":"success"}'
elif 'gae_proxy_enable' in reqs:
gae_proxy_enable = int(reqs['gae_proxy_enable'][0])
gae_proxy_enable = int(reqs['gae_proxy_enable'])
if gae_proxy_enable != 0 and gae_proxy_enable != 1:
data = '{"res":"fail, gae_proxy_enable:%s"}' % gae_proxy_enable
else:
Expand All @@ -540,7 +542,7 @@ def req_config_handler(self):
self.load_module_menus()
data = '{"res":"success"}'
elif 'x_tunnel_enable' in reqs:
x_tunnel_enable = int(reqs['x_tunnel_enable'][0])
x_tunnel_enable = int(reqs['x_tunnel_enable'])
if x_tunnel_enable != 0 and x_tunnel_enable != 1:
data = '{"res":"fail, x_tunnel_enable:%s"}' % x_tunnel_enable
else:
Expand All @@ -553,7 +555,7 @@ def req_config_handler(self):
self.load_module_menus()
data = '{"res":"success"}'
elif 'smart_router_enable' in reqs:
smart_router_enable = int(reqs['smart_router_enable'][0])
smart_router_enable = int(reqs['smart_router_enable'])
if smart_router_enable != 0 and smart_router_enable != 1:
data = '{"res":"fail, smart_router_enable:%s"}' % smart_router_enable
else:
Expand All @@ -566,7 +568,7 @@ def req_config_handler(self):
self.load_module_menus()
data = '{"res":"success"}'
elif 'postUpdateStat' in reqs:
postUpdateStat = reqs['postUpdateStat'][0]
postUpdateStat = reqs['postUpdateStat']
if postUpdateStat not in ["noChange", "isNew", "isPostUpdate"]:
data = '{"res":"fail, postUpdateStat:%s"}' % postUpdateStat
else:
Expand All @@ -591,10 +593,10 @@ def req_update_handler(self):
if data == '' or data[0] != '{':
data = '{"type":"%s"}' % data
elif reqs['cmd'] == ['set_info']:
update_from_github.update_info = reqs['info'][0]
update_from_github.update_info = reqs['info']
data = '{"res":"success"}'
elif reqs['cmd'] == ['start_check']:
update_from_github.init_update_info(reqs['check_update'][0])
update_from_github.init_update_info(reqs['check_update'])
update.check_update()
data = '{"res":"success"}'
elif reqs['cmd'] == ['get_progress']:
Expand All @@ -606,16 +608,16 @@ def req_update_handler(self):
github_versions[0][1], github_versions[1][1], current_version)
xlog.info("%s", data)
elif reqs['cmd'] == ['update_version']:
version = reqs['version'][0]
version = reqs['version']

checkhash = 1
if 'checkhash' in reqs and reqs['checkhash'][0] == '0':
if 'checkhash' in reqs and reqs['checkhash'] == '0':
checkhash = 0

update_from_github.start_update_version(version, checkhash)
data = '{"res":"success"}'
elif reqs['cmd'] == ['set_localversion']:
version = reqs['version'][0]
version = reqs['version']

if update_from_github.update_current_version(version):
data = '{"res":"success"}'
Expand All @@ -631,7 +633,7 @@ def req_update_handler(self):
s += ' { "v":"%s" , "folder":"%s" } ' % (v[0], v[1])
data = '[ %s ]' % (s)
elif reqs['cmd'] == ['del_localversion']:
if update_from_github.del_version(reqs['version'][0]):
if update_from_github.del_version(reqs['version']):
data = '{"res":"success"}'
else:
data = '{"res":"fail"}'
Expand All @@ -654,12 +656,12 @@ def req_config_proxy_handler(self):
}
data = json.dumps(data)
elif reqs['cmd'] == ['set_config']:
enable = int(reqs['enable'][0])
type = reqs['type'][0]
host = reqs['host'][0]
port = int(reqs['port'][0])
user = reqs['user'][0]
passwd = reqs['passwd'][0]
enable = int(reqs['enable'])
type = reqs['type']
host = reqs['host']
port = int(reqs['port'])
user = reqs['user']
passwd = reqs['passwd']

if int(enable) and not test_proxy(type, host, port, user, passwd):
return self.send_response('text/html', '{"res":"fail", "reason": "test proxy fail"}')
Expand Down Expand Up @@ -755,44 +757,44 @@ def set_proxy_applist(self):

def req_init_module_handler(self):
req = urlparse(self.path).query
reqs = parse_qs(req, keep_blank_values=True)
reqs = self.unpack_reqs(parse_qs(req, keep_blank_values=True))
data = ''

try:
module = reqs['module'][0]
module = reqs['module']
config.load()

if reqs['cmd'] == ['start']:
if reqs['cmd'] == 'start':
result = module_init.start(module)
data = '{ "module": "%s", "cmd": "start", "result": "%s" }' % (module, result)
elif reqs['cmd'] == ['stop']:
elif reqs['cmd'] == 'stop':
result = module_init.stop(module)
data = '{ "module": "%s", "cmd": "stop", "result": "%s" }' % (module, result)
elif reqs['cmd'] == ['restart']:
elif reqs['cmd'] == 'restart':
result_stop = module_init.stop(module)
result_start = module_init.start(module)
data = '{ "module": "%s", "cmd": "restart", "stop_result": "%s", "start_result": "%s" }' % (
module, result_stop, result_start)
except Exception as e:
xlog.exception("init_module except:%s", e)

self.send_response("text/html", data)
self.send_response("text/html", data, headers={"Access-Control-Allow-Origin": "*"})

def req_log_handler(self):
req = urlparse(self.path).query
reqs = parse_qs(req, keep_blank_values=True)
reqs = self.unpack_reqs(parse_qs(req, keep_blank_values=True))
data = ''

if reqs["cmd"]:
cmd = reqs["cmd"][0]
cmd = reqs["cmd"]
else:
cmd = "get_last"

if cmd == "get_last":
max_line = int(reqs["max_line"][0])
max_line = int(reqs["max_line"])
data = xlog.get_last_lines(max_line)
elif cmd == "get_new":
last_no = int(reqs["last_no"][0])
last_no = int(reqs["last_no"])
data = xlog.get_new_lines(last_no)
else:
xlog.error('xtunnel log cmd:%s', cmd)
Expand Down
2 changes: 1 addition & 1 deletion code/default/lib/noarch/front_base/boringssl_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def close(self):

self.socket_closed = True
if self._on_close:
self._on_close(self.ip_str)
self._on_close(self.ip_str, self.sni)

def __del__(self):
self.close()
Expand Down
Loading

0 comments on commit 760fd37

Please sign in to comment.