Skip to content

Commit

Permalink
feat(xray-core): Add XHTTP an alias of SplitHTTP (#1417)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMohammad20000 authored Nov 5, 2024
1 parent 39a9626 commit 36a6e9f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/subscription/clash.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def make_node(self,

def add(self, remark: str, address: str, inbound: dict, settings: dict):
# not supported by clash
if inbound['network'] in ("kcp", "splithttp"):
if inbound['network'] in ("kcp", "splithttp", "xhttp"):
return

proxy_remark = self._remark_validation(remark)
Expand Down Expand Up @@ -342,7 +342,7 @@ def make_node(self,

def add(self, remark: str, address: str, inbound: dict, settings: dict):
# not supported by clash-meta
if inbound['network'] in ("kcp", "splithttp") or (inbound['network'] == "quic" and inbound["header_type"] != "none"):
if inbound['network'] in ("kcp", "splithttp", "xhttp") or (inbound['network'] == "quic" and inbound["header_type"] != "none"):
return

proxy_remark = self._remark_validation(remark)
Expand Down
2 changes: 1 addition & 1 deletion app/subscription/singbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def add(self, remark: str, address: str, inbound: dict, settings: dict):
path = inbound["path"]

# not supported by sing-box
if net in ("kcp", "splithttp") or (net == "quic" and inbound["header_type"] != "none"):
if net in ("kcp", "splithttp", "xhttp") or (net == "quic" and inbound["header_type"] != "none"):
return

if net in ("grpc", "gun"):
Expand Down
38 changes: 19 additions & 19 deletions app/subscription/v2ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,17 @@ def vmess(
else:
payload["mode"] = "gun"

elif net == "splithttp":
elif net in ("splithttp", "xhttp"):
payload["scMaxEachPostBytes"] = sc_max_each_post_bytes
payload["scMaxConcurrentPosts"] = sc_max_concurrent_posts
payload["scMinPostsIntervalMs"] = sc_min_posts_interval_ms
payload["xPaddingBytes"] = x_padding_bytes

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 @@ -272,7 +272,7 @@ def vless(cls,
payload['key'] = path
payload["quicSecurity"] = host

elif net == "splithttp":
elif net in ("splithttp", "xhttp"):
payload["path"] = path
payload["host"] = host
payload["scMaxEachPostBytes"] = sc_max_each_post_bytes
Expand Down Expand Up @@ -307,10 +307,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 @@ -356,7 +356,7 @@ def trojan(cls,
else:
payload["mode"] = "gun"

elif net == "splithttp":
elif net in ("splithttp", "xhttp"):
payload["path"] = path
payload["host"] = host
payload["scMaxEachPostBytes"] = sc_max_each_post_bytes
Expand Down Expand Up @@ -394,20 +394,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 @@ -863,7 +863,7 @@ def make_stream_setting(self,
elif net == "httpupgrade":
network_setting = self.httpupgrade_config(
path=path, host=host, random_user_agent=random_user_agent)
elif net == "splithttp":
elif net in ("splithttp", "xhttp"):
network_setting = self.splithttp_config(path=path, host=host, random_user_agent=random_user_agent,
sc_max_each_post_bytes=sc_max_each_post_bytes,
sc_max_concurrent_posts=sc_max_concurrent_posts,
Expand Down
2 changes: 1 addition & 1 deletion app/xray/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _resolve_inbounds(self):
host = net_settings.get('host', '')
settings['host'] = [host]

elif net == 'splithttp':
elif net in ('splithttp','xhttp'):
settings['path'] = net_settings.get('path', '')
host = net_settings.get('host', '')
settings['host'] = [host]
Expand Down

0 comments on commit 36a6e9f

Please sign in to comment.