Skip to content

Commit

Permalink
fix(subscription): mux enable in json config
Browse files Browse the repository at this point in the history
  • Loading branch information
M03ED committed Mar 11, 2024
1 parent 46276d0 commit af0cc98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions app/subscription/singbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ class SingBoxConfiguration(str):
def __init__(self):
template = render_template(SINGBOX_SUBSCRIPTION_TEMPLATE)
self.config = json.loads(template)
mux_template = render_template(MUX_TEMPLATE)
mux_json = json.loads(mux_template)
self.mux_config = mux_json["sing-box"]
self.mux_template = render_template(MUX_TEMPLATE)

def add_outbound(self, outbound_data):
self.config["outbounds"].append(outbound_data)
Expand Down Expand Up @@ -178,7 +176,10 @@ def make_outbound(self,
pbk=pbk, sid=sid, alpn=alpn,
ais=ais)

config['multiplex'] = self.mux_config
mux_json = json.loads(self.mux_template)
mux_config = mux_json["sing-box"]

config['multiplex'] = mux_config
config['multiplex']["enabled"] = mux_enable

return config
Expand Down
9 changes: 5 additions & 4 deletions app/subscription/v2ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ class V2rayJsonConfig(str):
def __init__(self):
self.config = []
self.template = render_template(V2RAY_SUBSCRIPTION_TEMPLATE)
mux_template = render_template(MUX_TEMPLATE)
mux_json = json.loads(mux_template)
self.mux_config = mux_json["v2ray"]
self.mux_template = render_template(MUX_TEMPLATE)

def add_config(self, remarks, outbounds):
json_template = json.loads(self.template)
Expand Down Expand Up @@ -612,7 +610,10 @@ def add(self, remark: str, address: str, inbound: dict, settings: dict):
dialer_proxy=dialer_proxy
)

outbound["mux"] = self.mux_config
mux_json = json.loads(self.mux_template)
mux_config = mux_json["v2ray"]

outbound["mux"] = mux_config
outbound["mux"]["enabled"] = bool(inbound.get('mux_enable', False))

self.add_config(remarks=remark, outbounds=outbounds)

0 comments on commit af0cc98

Please sign in to comment.