Skip to content

Commit

Permalink
feat: Add random selection from reality shortIds (#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMohammad20000 authored Dec 4, 2024
1 parent f5ca421 commit c5d3263
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/subscription/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
DISABLED_STATUS_TEXT,
EXPIRED_STATUS_TEXT,
LIMITED_STATUS_TEXT,
ONHOLD_STATUS_TEXT
ONHOLD_STATUS_TEXT,
)

SERVER_IP = get_public_ip()
Expand Down Expand Up @@ -272,6 +272,9 @@ def process_inbounds_and_tags(
salt = secrets.token_hex(8)
sni = random.choice(sni_list).replace("*", salt)

if sids := inbound.get("sids"):
inbound["sid"] = random.choice(sids)

req_host = ""
req_host_list = host["host"] or inbound["host"]
if req_host_list:
Expand Down
3 changes: 2 additions & 1 deletion app/xray/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def _resolve_inbounds(self):
f"You need to provide publicKey in realitySettings of {inbound['tag']}")

try:
settings['sid'] = tls_settings.get('shortIds')[0]
settings['sids'] = tls_settings.get('shortIds')
settings['sids'][0] # check if there is any shortIds
except (IndexError, TypeError):
raise ValueError(
f"You need to define at least one shortID in realitySettings of {inbound['tag']}")
Expand Down

0 comments on commit c5d3263

Please sign in to comment.