From 16ed7ec1bcd73a08248781f30d733685b8f7970a Mon Sep 17 00:00:00 2001 From: SaintShit Date: Tue, 28 May 2024 20:50:52 +0330 Subject: [PATCH] fix: mux settings --- app/subscription/clash.py | 12 ++++++------ app/subscription/singbox.py | 16 ++++++---------- app/subscription/v2ray.py | 6 +++--- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/app/subscription/clash.py b/app/subscription/clash.py index 7e540d17..e999055b 100644 --- a/app/subscription/clash.py +++ b/app/subscription/clash.py @@ -59,7 +59,7 @@ def make_node(self, udp: bool = True, alpn: str = '', ais: bool = '', - mux_enable : bool = False): + mux_enable: bool = False): if type == 'shadowsocks': type = 'ss' @@ -128,9 +128,9 @@ def make_node(self, mux_json = json.loads(self.mux_template) mux_config = mux_json["clash"] - net_opts['smux'] = mux_config - if net_opts['smux']["enabled"]: - net_opts['smux']["enabled"] = mux_enable + if mux_enable: + net_opts['smux'] = mux_config + net_opts['smux']["enabled"] = True return node @@ -189,7 +189,7 @@ def make_node(self, pbk: str = '', sid: str = '', ais: bool = '', - mux_enable : bool = False): + mux_enable: bool = False): node = super().make_node( name=name, type=type, @@ -263,4 +263,4 @@ def add(self, remark: str, address: str, inbound: dict, settings: dict): node['password'] = settings['password'] node['cipher'] = settings['method'] self.data['proxies'].append(node) - self.proxy_remarks.append(remark) \ No newline at end of file + self.proxy_remarks.append(remark) diff --git a/app/subscription/singbox.py b/app/subscription/singbox.py index 17fd7239..01e14cab 100644 --- a/app/subscription/singbox.py +++ b/app/subscription/singbox.py @@ -149,7 +149,7 @@ def make_outbound(self, "server_port": port, } - if net in ('tcp', 'kcp') and headers != 'http' and tls != 'none': + if net in ('tcp', 'kcp') and headers != 'http' and (tls or tls != 'none'): if flow: config["flow"] = flow @@ -159,7 +159,6 @@ def make_outbound(self, elif net in ['tcp'] and headers == 'http': net = 'http' - if net in ['http', 'ws', 'quic', 'grpc', 'httpupgrade']: max_early_data = None early_data_header_name = None @@ -184,14 +183,11 @@ def make_outbound(self, config['tls'] = self.tls_config(sni=sni, fp=fp, tls=tls, pbk=pbk, sid=sid, alpn=alpn, ais=ais) - - # Singbox mux is not compatible with xray mux - # Since marzban doesnt support singbox core at server side at the moment - sinbox-mux should not be enabled at all - # if mux_enable: - # mux_json = json.loads(self.mux_template) - # mux_config = mux_json["sing-box"] - # config['multiplex'] = mux_config - # config['multiplex']["enabled"] = mux_enable + if mux_enable: + mux_json = json.loads(self.mux_template) + mux_config = mux_json["sing-box"] + config['multiplex'] = mux_config + config['multiplex']["enabled"] = mux_enable return config diff --git a/app/subscription/v2ray.py b/app/subscription/v2ray.py index d36ff0c9..3fb3a494 100644 --- a/app/subscription/v2ray.py +++ b/app/subscription/v2ray.py @@ -631,8 +631,8 @@ def add(self, remark: str, address: str, inbound: dict, settings: dict): mux_json = json.loads(self.mux_template) mux_config = mux_json["v2ray"] - outbound["mux"] = mux_config - if outbound["mux"]["enabled"]: - outbound["mux"]["enabled"] = bool(inbound.get('mux_enable', False)) + if inbound.get('mux_enable', False): + outbound["mux"] = mux_config + outbound["mux"]["enabled"] = True self.add_config(remarks=remark, outbounds=outbounds)