Skip to content

Commit

Permalink
xhttp: add support for scStreamUpServerSecs (#1627)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMohammad20000 authored Jan 30, 2025
1 parent 2d0d161 commit 8d26e43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/subscription/v2ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def add(self, remark: str, address: str, inbound: dict, settings: dict):
noGRPCHeader=inbound.get("noGRPCHeader"),
heartbeatPeriod=inbound.get("heartbeatPeriod", 0),
keepAlivePeriod=inbound.get("keepAlivePeriod", 0),
scStreamUpServerSecs=inbound.get("scStreamUpServerSecs"),
xmux=inbound.get("xmux", {}),
downloadSettings=inbound.get("downloadSettings", {})
)
Expand Down Expand Up @@ -113,6 +114,7 @@ def add(self, remark: str, address: str, inbound: dict, settings: dict):
noGRPCHeader=inbound.get("noGRPCHeader"),
heartbeatPeriod=inbound.get("heartbeatPeriod", 0),
keepAlivePeriod=inbound.get("keepAlivePeriod", 0),
scStreamUpServerSecs=inbound.get("scStreamUpServerSecs"),
xmux=inbound.get("xmux", {}),
downloadSettings=inbound.get("downloadSettings", {})
)
Expand Down Expand Up @@ -147,6 +149,7 @@ def add(self, remark: str, address: str, inbound: dict, settings: dict):
heartbeatPeriod=inbound.get("heartbeatPeriod", 0),
keepAlivePeriod=inbound.get("keepAlivePeriod", 0),
xmux=inbound.get("xmux", {}),
scStreamUpServerSecs=inbound.get("scStreamUpServerSecs"),
downloadSettings=inbound.get("downloadSettings", {})
)

Expand Down Expand Up @@ -191,6 +194,7 @@ def vmess(
mode: str = "",
noGRPCHeader: bool | None = None,
heartbeatPeriod: int | None = None,
scStreamUpServerSecs: int | None = None,
keepAlivePeriod: int = 0,
xmux: dict = {},
downloadSettings: dict = {},
Expand Down Expand Up @@ -249,6 +253,8 @@ def vmess(
extra["xPaddingBytes"] = x_padding_bytes
if noGRPCHeader is not None:
extra["noGRPCHeader"] = noGRPCHeader
if scStreamUpServerSecs is not None:
extra["scStreamUpServerSecs"] = scStreamUpServerSecs
if keepAlivePeriod > 0:
extra["keepAlivePeriod"] = keepAlivePeriod
if xmux:
Expand Down Expand Up @@ -298,6 +304,7 @@ def vless(cls,
mode: str = "",
noGRPCHeader: bool | None = None,
heartbeatPeriod: int | None = None,
scStreamUpServerSecs: int | None = None,
keepAlivePeriod: int = 0,
xmux: dict = {},
downloadSettings: dict = {},
Expand Down Expand Up @@ -338,6 +345,8 @@ def vless(cls,
extra["xPaddingBytes"] = x_padding_bytes
if noGRPCHeader is not None:
extra["noGRPCHeader"] = noGRPCHeader
if scStreamUpServerSecs is not None:
extra["scStreamUpServerSecs"] = scStreamUpServerSecs
if keepAlivePeriod > 0:
extra["keepAlivePeriod"] = keepAlivePeriod
if xmux:
Expand Down Expand Up @@ -414,6 +423,7 @@ def trojan(cls,
mode: str = "",
noGRPCHeader: bool | None = None,
heartbeatPeriod: int | None = None,
scStreamUpServerSecs: int | None = None,
keepAlivePeriod: int = 0,
xmux: dict = {},
downloadSettings: dict = {},
Expand Down Expand Up @@ -452,6 +462,8 @@ def trojan(cls,
extra["noGRPCHeader"] = noGRPCHeader
if keepAlivePeriod > 0:
extra["keepAlivePeriod"] = keepAlivePeriod
if scStreamUpServerSecs is not None:
extra["scStreamUpServerSecs"] = scStreamUpServerSecs
if xmux:
extra["xmux"] = xmux
if downloadSettings:
Expand Down Expand Up @@ -632,6 +644,7 @@ def splithttp_config(self, path: str = "", host: str = "", random_user_agent: bo
downloadSettings: dict = {},
mode: str = "",
noGRPCHeader: bool | None = None,
scStreamUpServerSecs: int | None = None,
keepAlivePeriod: int = 0,
) -> dict:
config = copy.deepcopy(self.settings.get("splithttpSettings", {}))
Expand All @@ -654,6 +667,8 @@ def splithttp_config(self, path: str = "", host: str = "", random_user_agent: bo
extra["xPaddingBytes"] = x_padding_bytes
if noGRPCHeader is not None:
extra["noGRPCHeader"] = noGRPCHeader
if scStreamUpServerSecs is not None:
extra["scStreamUpServerSecs"] = scStreamUpServerSecs
if keepAlivePeriod > 0:
extra["keepAlivePeriod"] = keepAlivePeriod
if xmux:
Expand Down Expand Up @@ -966,6 +981,7 @@ def make_stream_setting(self,
downloadSettings: dict = {},
mode: str = "",
noGRPCHeader: bool | None = None,
scStreamUpServerSecs: int | None = None,
heartbeatPeriod: int = 0,
keepAlivePeriod: int = 0,
) -> dict:
Expand Down Expand Up @@ -1002,6 +1018,7 @@ def make_stream_setting(self,
mode=mode,
noGRPCHeader=noGRPCHeader,
keepAlivePeriod=keepAlivePeriod,
scStreamUpServerSecs=scStreamUpServerSecs,
)
else:
network_setting = {}
Expand Down Expand Up @@ -1114,6 +1131,7 @@ def add(self, remark: str, address: str, inbound: dict, settings: dict):
noGRPCHeader=inbound.get("noGRPCHeader"),
heartbeatPeriod=inbound.get("heartbeatPeriod", 0),
keepAlivePeriod=inbound.get("keepAlivePeriod", 0),
scStreamUpServerSecs=inbound.get("scStreamUpServerSecs"),
)

mux_json = json.loads(self.mux_template)
Expand Down
1 change: 1 addition & 0 deletions app/xray/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def _resolve_inbounds(self):
settings['downloadSettings'] = net_settings.get('downloadSettings', {})
settings["mode"] = net_settings.get("mode", "auto")
settings["keepAlivePeriod"] = net_settings.get("keepAlivePeriod", 0)
settings["scStreamUpServerSecs"] = net_settings.get("scStreamUpServerSecs")

elif net == 'kcp':
header = net_settings.get('header', {})
Expand Down

0 comments on commit 8d26e43

Please sign in to comment.