Skip to content

Commit 7c83222

Browse files
fix(subscription): create raw custom xray json
1 parent 223482d commit 7c83222

File tree

1 file changed

+32
-39
lines changed

1 file changed

+32
-39
lines changed

app/subscription/xray.py

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ def __init__(self):
3030
"httpupgrade": self._transport_httpupgrade,
3131
"splithttp": self._transport_xhttp,
3232
"xhttp": self._transport_xhttp,
33+
"quic": self._transport_quic,
3334
"grpc": self._transport_grpc,
3435
"gun": self._transport_grpc,
3536
"tcp": self._transport_tcp,
37+
"raw": self._transport_tcp,
3638
"kcp": self._transport_kcp,
37-
"quic": self._transport_quic,
3839
"h2": self._transport_http,
3940
}
4041

@@ -247,31 +248,27 @@ def _transport_quic(self, config: QUICTransportConfig, path: str) -> dict:
247248
"""Handle QUIC transport - only gets QUIC config"""
248249
host = config.host if isinstance(config.host, str) else (config.host[0] if config.host else "")
249250

250-
return self._normalize_and_remove_none_values(
251-
{
252-
"security": host,
253-
"header": {"type": config.header_type},
254-
"key": path,
255-
}
256-
)
251+
return self._normalize_and_remove_none_values({
252+
"security": host,
253+
"header": {"type": config.header_type},
254+
"key": path,
255+
})
257256

258257
def _transport_kcp(self, config: KCPTransportConfig, path: str) -> dict:
259258
"""Handle KCP transport - only gets KCP config"""
260259
host = config.host if isinstance(config.host, str) else (config.host[0] if config.host else "")
261260

262-
return self._normalize_and_remove_none_values(
263-
{
264-
"header": {"type": config.header_type, "domain": host},
265-
"mtu": config.mtu if config.mtu else 1350,
266-
"tti": config.tti if config.tti else 50,
267-
"uplinkCapacity": config.uplink_capacity if config.uplink_capacity else 12,
268-
"downlinkCapacity": config.downlink_capacity if config.downlink_capacity else 100,
269-
"congestion": config.congestion,
270-
"readBufferSize": config.read_buffer_size if config.read_buffer_size else 2,
271-
"writeBufferSize": config.write_buffer_size if config.write_buffer_size else 2,
272-
"seed": path,
273-
}
274-
)
261+
return self._normalize_and_remove_none_values({
262+
"header": {"type": config.header_type, "domain": host},
263+
"mtu": config.mtu if config.mtu else 1350,
264+
"tti": config.tti if config.tti else 50,
265+
"uplinkCapacity": config.uplink_capacity if config.uplink_capacity else 12,
266+
"downlinkCapacity": config.downlink_capacity if config.downlink_capacity else 100,
267+
"congestion": config.congestion,
268+
"readBufferSize": config.read_buffer_size if config.read_buffer_size else 2,
269+
"writeBufferSize": config.write_buffer_size if config.write_buffer_size else 2,
270+
"seed": path,
271+
})
275272

276273
def _apply_transport(self, network: str, inbound: SubscriptionInboundData, path: str) -> dict | None:
277274
"""Apply transport settings using registry pattern"""
@@ -287,17 +284,15 @@ def _apply_tls(self, tls_config: TLSConfig, security: str) -> dict:
287284
sni = tls_config.sni if isinstance(tls_config.sni, str) else (tls_config.sni[0] if tls_config.sni else None)
288285

289286
if security == "reality":
290-
return self._normalize_and_remove_none_values(
291-
{
292-
"serverName": sni,
293-
"fingerprint": tls_config.fingerprint,
294-
"show": False,
295-
"publicKey": tls_config.reality_public_key,
296-
"shortId": tls_config.reality_short_id,
297-
"spiderX": tls_config.reality_spx,
298-
"mldsa65Verify": tls_config.mldsa65_verify,
299-
}
300-
)
287+
return self._normalize_and_remove_none_values({
288+
"serverName": sni,
289+
"fingerprint": tls_config.fingerprint,
290+
"show": False,
291+
"publicKey": tls_config.reality_public_key,
292+
"shortId": tls_config.reality_short_id,
293+
"spiderX": tls_config.reality_spx,
294+
"mldsa65Verify": tls_config.mldsa65_verify,
295+
})
301296
else: # tls
302297
config = {
303298
"serverName": sni,
@@ -361,13 +356,11 @@ def _download_config(self, download_settings: SubscriptionInboundData, link_form
361356
sockopt=sockopt,
362357
)
363358

364-
return self._normalize_and_remove_none_values(
365-
{
366-
"address": download_settings.address,
367-
"port": self._select_port(download_settings.port),
368-
**stream_settings,
369-
}
370-
)
359+
return self._normalize_and_remove_none_values({
360+
"address": download_settings.address,
361+
"port": self._select_port(download_settings.port),
362+
**stream_settings,
363+
})
371364

372365
# ========== Protocol Builders (Registry Methods) ==========
373366

0 commit comments

Comments
 (0)