Skip to content

Commit

Permalink
don't send keepAlivePeriod if it not in the config (#1517)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMohammad20000 authored Dec 15, 2024
1 parent 5c217e9 commit 43ccc2d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/subscription/v2ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from typing import Union
from urllib.parse import quote
from uuid import UUID
from app.utils.helpers import UUIDEncoder

from jinja2.exceptions import TemplateNotFound

from app.subscription.funcs import get_grpc_gun, get_grpc_multi
from app.templates import render_template
from app.utils.helpers import UUIDEncoder
from config import (
EXTERNAL_CONFIG,
GRPC_USER_AGENT_TEMPLATE,
Expand Down Expand Up @@ -240,11 +240,12 @@ def vmess(
"scMinPostsIntervalMs": sc_min_posts_interval_ms,
"xPaddingBytes": x_padding_bytes,
"noGRPCHeader": noGRPCHeader,
"keepAlivePeriod": keepAlivePeriod,
}
if xmux:
extra["xmux"] = xmux
payload["type"] = mode
if keepAlivePeriod > 0:
extra["keepAlivePeriod"] = keepAlivePeriod
payload["extra"] = extra

elif net == "ws":
Expand Down Expand Up @@ -320,8 +321,9 @@ def vless(cls,
"scMinPostsIntervalMs": sc_min_posts_interval_ms,
"xPaddingBytes": x_padding_bytes,
"noGRPCHeader": noGRPCHeader,
"keepAlivePeriod": keepAlivePeriod,
}
if keepAlivePeriod > 0:
extra["keepAlivePeriod"] = keepAlivePeriod
if xmux:
extra["xmux"] = xmux
payload["extra"] = json.dumps(extra)
Expand Down Expand Up @@ -423,8 +425,9 @@ def trojan(cls,
"scMinPostsIntervalMs": sc_min_posts_interval_ms,
"xPaddingBytes": x_padding_bytes,
"noGRPCHeader": noGRPCHeader,
"keepAlivePeriod": keepAlivePeriod,
}
if keepAlivePeriod > 0:
extra["keepAlivePeriod"] = keepAlivePeriod
if xmux:
extra["xmux"] = xmux
payload["extra"] = json.dumps(extra)
Expand Down Expand Up @@ -518,7 +521,7 @@ def add_config(self, remarks, outbounds):
def render(self, reverse=False):
if reverse:
self.config.reverse()
return json.dumps(self.config, indent=4,cls=UUIDEncoder)
return json.dumps(self.config, indent=4, cls=UUIDEncoder)

@staticmethod
def tls_config(sni=None, fp=None, alpn=None, ais: bool = False) -> dict:
Expand Down Expand Up @@ -617,7 +620,8 @@ def splithttp_config(self, path: str = "", host: str = "", random_user_agent: bo
config["noGRPCHeader"] = noGRPCHeader
if xmux:
config["xmux"] = xmux
config["keepAlivePeriod"] = keepAlivePeriod
if keepAlivePeriod > 0:
config["keepAlivePeriod"] = keepAlivePeriod
# core will ignore unknown variables

return config
Expand Down

0 comments on commit 43ccc2d

Please sign in to comment.