Skip to content

Commit

Permalink
fix: xhttp extra in v2ray links (#1613)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMohammad20000 authored Jan 18, 2025
1 parent 99a3b27 commit 2d0d161
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app/subscription/v2ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ def vmess(
if downloadSettings:
extra["downloadSettings"] = downloadSettings
payload["type"] = mode
payload["extra"] = (json.dumps(extra)).replace(" ", "")
if extra:
payload["extra"] = (json.dumps(extra)).replace(" ", "")

elif net == "ws":
if heartbeatPeriod:
Expand Down Expand Up @@ -343,7 +344,8 @@ def vless(cls,
extra["xmux"] = xmux
if downloadSettings:
extra["downloadSettings"] = downloadSettings
payload["extra"] = (json.dumps(extra)).replace(" ", "")
if extra:
payload["extra"] = (json.dumps(extra)).replace(" ", "")

elif net == 'kcp':
payload['seed'] = path
Expand Down Expand Up @@ -454,7 +456,8 @@ def trojan(cls,
extra["xmux"] = xmux
if downloadSettings:
extra["downloadSettings"] = downloadSettings
payload["extra"] = (json.dumps(extra)).replace(" ", "")
if extra:
payload["extra"] = (json.dumps(extra)).replace(" ", "")

elif net == 'quic':
payload['key'] = path
Expand Down Expand Up @@ -522,15 +525,17 @@ def __init__(self):
else:
self.user_agent_list = []

grpc_user_agent_data = json.loads(render_template(GRPC_USER_AGENT_TEMPLATE))
grpc_user_agent_data = json.loads(
render_template(GRPC_USER_AGENT_TEMPLATE))

if 'list' in grpc_user_agent_data and isinstance(grpc_user_agent_data['list'], list):
self.grpc_user_agent_data = grpc_user_agent_data['list']
else:
self.grpc_user_agent_data = []

try:
self.settings = json.loads(render_template(V2RAY_SETTINGS_TEMPLATE))
self.settings = json.loads(
render_template(V2RAY_SETTINGS_TEMPLATE))
except TemplateNotFound:
self.settings = {}

Expand Down Expand Up @@ -603,7 +608,8 @@ def ws_config(self, path: str = "", host: str = "", random_user_agent: bool = Fa
return wsSettings

def httpupgrade_config(self, path: str = "", host: str = "", random_user_agent: bool = False) -> dict:
httpupgradeSettings = copy.deepcopy(self.settings.get("httpupgradeSettings", {}))
httpupgradeSettings = copy.deepcopy(
self.settings.get("httpupgradeSettings", {}))

if "headers" not in httpupgradeSettings:
httpupgradeSettings["headers"] = {}
Expand Down Expand Up @@ -922,7 +928,8 @@ def make_noises(noises: str) -> list:
def make_dialer_outbound(fragment: str = "", noises: str = "") -> Union[dict, None]:
dialer_settings = {}
if fragment:
dialer_settings["fragment"] = V2rayJsonConfig.make_fragment(fragment)
dialer_settings["fragment"] = V2rayJsonConfig.make_fragment(
fragment)
if noises:
dialer_settings["noises"] = V2rayJsonConfig.make_noises(noises)

Expand Down

0 comments on commit 2d0d161

Please sign in to comment.