Skip to content

Commit

Permalink
fix(subscription): tcp no tls empty header type
Browse files Browse the repository at this point in the history
  • Loading branch information
M03ED committed Aug 30, 2024
1 parent 3f1c86a commit 241d823
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
50 changes: 33 additions & 17 deletions app/subscription/v2ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ def vmess(
payload["scMinPostsIntervalMs"] = sc_min_posts_interval_ms

return (
"vmess://"
+ base64.b64encode(
json.dumps(payload, sort_keys=True).encode("utf-8")
).decode()
"vmess://"
+ base64.b64encode(
json.dumps(payload, sort_keys=True).encode("utf-8")
).decode()
)

@classmethod
Expand Down Expand Up @@ -303,10 +303,10 @@ def vless(cls,
payload["spx"] = spx

return (
"vless://"
+ f"{id}@{address}:{port}?"
+ urlparse.urlencode(payload)
+ f"#{(urlparse.quote(remark))}"
"vless://"
+ f"{id}@{address}:{port}?"
+ urlparse.urlencode(payload)
+ f"#{(urlparse.quote(remark))}"
)

@classmethod
Expand Down Expand Up @@ -392,20 +392,20 @@ def trojan(cls,
payload["spx"] = spx

return (
"trojan://"
+ f"{urlparse.quote(password, safe=':')}@{address}:{port}?"
+ urlparse.urlencode(payload)
+ f"#{urlparse.quote(remark)}"
"trojan://"
+ f"{urlparse.quote(password, safe=':')}@{address}:{port}?"
+ urlparse.urlencode(payload)
+ f"#{urlparse.quote(remark)}"
)

@classmethod
def shadowsocks(
cls, remark: str, address: str, port: int, password: str, method: str
):
return (
"ss://"
+ base64.b64encode(f"{method}:{password}".encode()).decode()
+ f"@{address}:{port}#{urlparse.quote(remark)}"
"ss://"
+ base64.b64encode(f"{method}:{password}".encode()).decode()
+ f"@{address}:{port}#{urlparse.quote(remark)}"
)


Expand Down Expand Up @@ -564,11 +564,27 @@ def grpc_config(self, path=None, host=None, multiMode=False, random_user_agent=N
def tcp_config(self, headers="none", path=None, host=None, random_user_agent=None):
if headers == "http":
config = copy.deepcopy(self.settings.get("tcphttpSettings", {
"header": {}
"header": {
"request": {
"headers": {
"Accept-Encoding": [
"gzip", "deflate"
],
"Connection": [
"keep-alive"
],
"Pragma": "no-cache"
},
"method": "GET",
"version": "1.1"
}
}
}))
else:
config = copy.deepcopy(self.settings.get("tcpSettings", {
"header": {}
"header": {
"type": "none"
}
}))
if "header" not in config:
config["header"] = {}
Expand Down
4 changes: 3 additions & 1 deletion app/templates/v2ray/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"header": {}
},
"tcpSettings": {
"header": {}
"header": {
"type": "none"
}
},
"tcphttpSettings": {
"header": {
Expand Down

0 comments on commit 241d823

Please sign in to comment.