Skip to content

Commit

Permalink
Merge pull request #842 from M03ED/dev
Browse files Browse the repository at this point in the history
fix: tcp http in v2ray json config
SaintShit authored Mar 13, 2024
2 parents db53013 + e403879 commit 9732c3c
Showing 3 changed files with 23 additions and 20 deletions.
9 changes: 5 additions & 4 deletions app/subscription/singbox.py
Original file line number Diff line number Diff line change
@@ -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)
@@ -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
32 changes: 17 additions & 15 deletions app/subscription/v2ray.py
Original file line number Diff line number Diff line change
@@ -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)
@@ -291,21 +289,22 @@ def tcp_http_config(path=None, host=None):
tcpSettings["header"] = {}
tcpSettings["header"]["type"] = "http"

tcpSettings["request"] = {}
tcpSettings["request"]["version"] = "1.1"
tcpSettings["header"]["request"] = {}
tcpSettings["header"]["request"]["version"] = "1.1"

tcpSettings["request"]["headers"] = {}
tcpSettings["request"]["method"] = "GET"
tcpSettings["request"]["headers"]["User-Agent"] = ""
tcpSettings["request"]["headers"]["Accept-Encoding"] = ["gzip, deflate"],
tcpSettings["request"]["headers"]["Connection"] = "keep-alive"
tcpSettings["request"]["headers"]["Pragma"] = "no-cache"
tcpSettings["header"]["request"]["headers"] = {}
tcpSettings["header"]["request"]["method"] = "GET"
tcpSettings["header"]["request"]["headers"]["User-Agent"] = []
tcpSettings["header"]["request"]["headers"]["Accept-Encoding"] = ["gzip, deflate"]
tcpSettings["header"]["request"]["headers"]["Connection"] = ["keep-alive"]
tcpSettings["header"]["request"]["headers"]["Pragma"] = "no-cache"

if path:
tcpSettings["request"]["path"] = [path]
tcpSettings["header"]["request"]["path"] = [path]

if host:
tcpSettings["request"]["headers"]["Host"] = [host]
tcpSettings["header"]["request"]["headers"]["Host"] = [host]


return tcpSettings

@@ -560,7 +559,7 @@ def add(self, remark: str, address: str, inbound: dict, settings: dict):
outbound["settings"]["vnext"] = vnext

elif inbound['protocol'] == 'vless':
if net in ('tcp', 'kcp') and headers != 'http' and tls:
if net in ('tcp', 'kcp') and headers != 'http' and tls in ('tls', 'reality'):
flow = settings.get('flow', '')
else:
flow = None
@@ -611,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)
2 changes: 1 addition & 1 deletion app/templates/mux/default.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"v2ray": {
"enabled": true,
"enabled": false,
"concurrency": 8,
"xudpConcurrency": 8,
"xudpProxyUDP443": "reject"

0 comments on commit 9732c3c

Please sign in to comment.