From 05bd2e5cff03d5bb5e62745910f7c52d545df08b Mon Sep 17 00:00:00 2001 From: chenhuajian Date: Fri, 27 Nov 2020 12:53:04 +0800 Subject: [PATCH] fix bug --- v2ray_util/__init__.py | 2 +- v2ray_util/config_modify/multiple.py | 2 +- v2ray_util/config_modify/stream.py | 16 +++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/v2ray_util/__init__.py b/v2ray_util/__init__.py index 6ec51f3f..0b5dfcbf 100644 --- a/v2ray_util/__init__.py +++ b/v2ray_util/__init__.py @@ -1,3 +1,3 @@ -__version__ = '3.8.5' +__version__ = '3.8.6' from .util_core.trans import _ \ No newline at end of file diff --git a/v2ray_util/config_modify/multiple.py b/v2ray_util/config_modify/multiple.py index 83b59034..64b17f1e 100644 --- a/v2ray_util/config_modify/multiple.py +++ b/v2ray_util/config_modify/multiple.py @@ -9,7 +9,7 @@ @restart(True) def new_port(new_stream=None): - if new_stream not in StreamType._value2member_map_: + if new_stream != None and new_stream not in StreamType._value2member_map_: print(ColorStr.red("{} not support!".format(new_stream))) return new_port = "" diff --git a/v2ray_util/config_modify/stream.py b/v2ray_util/config_modify/stream.py index 6b34dcae..1d0499f1 100644 --- a/v2ray_util/config_modify/stream.py +++ b/v2ray_util/config_modify/stream.py @@ -99,12 +99,14 @@ def select(self, sType): def random_kcp(self): kcp_list = (StreamType.KCP_SRTP, StreamType.KCP_UTP, StreamType.KCP_WECHAT, StreamType.KCP_DTLS, StreamType.KCP_WG) choice = random.randint(0, 4) - print("{}: {} \n".format(_("random generate (srtp | wechat-video | utp | dtls | wireguard) fake header, new protocol"), ColorStr.green(kcp_list[choice]))) + print("{}: {} \n".format(_("random generate (srtp | wechat-video | utp | dtls | wireguard) fake header, new protocol"), ColorStr.green(kcp_list[choice].value))) self.select(kcp_list[choice]) @restart() def modify(group=None, sType=None): + need_restart = False if group == None: + need_restart = True gs = GroupSelector(_('modify protocol')) group = gs.group @@ -114,11 +116,14 @@ def modify(group=None, sType=None): sm = StreamModifier(group.tag, group.index) if sType != None: - sm.select(sType) + sm.select([v for v in StreamType if v.value == sType][0]) print(_("modify protocol success")) - return True + return + + if need_restart: + print("") + print("{}: {}".format(_("group protocol"), group.node_list[0].stream())) - print("{}: {}".format(_("group protocol"), group.node_list[0].stream())) print("") for index, stream_type in enumerate(sm.stream_type): print("{0}.{1}".format(index + 1, stream_type[1])) @@ -135,4 +140,5 @@ def modify(group=None, sType=None): print(_("V2ray MTProto/Shadowsocks not support https, close tls success!")) sm.select(sm.stream_type[choice - 1][0]) print(_("modify protocol success")) - return True \ No newline at end of file + if need_restart: + return True \ No newline at end of file