fix: match links to inbounds by index instead of grouping all inbound names

This commit is contained in:
SashegDev
2026-05-20 16:54:03 +00:00
parent ffb980536d
commit 0771b300e5
+14 -11
View File
@@ -417,31 +417,34 @@ async def get_subscription(request: Request, subscription_id: str, format: str =
all_links = [] all_links = []
seen_links = set() seen_links = set()
servers_processed = set() servers_processed = set()
server_links = {}
for srv, inbound in inbounds: for srv, inbound in inbounds:
srv_name = srv["name"] srv_name = srv["name"]
if srv_name in servers_processed:
continue
if srv_name not in servers_processed:
servers_processed.add(srv_name)
sub_path = srv["sub_path"].format(sub_id=subscription_id) sub_path = srv["sub_path"].format(sub_id=subscription_id)
url = f"{srv['subscription_url'].rstrip('/')}{sub_path}" url = f"{srv['subscription_url'].rstrip('/')}{sub_path}"
links = await fetch_vless_links(url) server_links[srv_name] = await fetch_vless_links(url)
servers_processed.add(srv_name) links = server_links.get(srv_name, [])
srv_inbounds = [ib for s, ib in inbounds if s["name"] == srv_name]
try:
link_idx = srv_inbounds.index(inbound)
except ValueError:
continue
for link in links: if link_idx >= len(links):
continue
link = links[link_idx]
clean_link = link.split('#')[0] clean_link = link.split('#')[0]
if clean_link in seen_links: if clean_link in seen_links:
continue continue
seen_links.add(clean_link) seen_links.add(clean_link)
srv_inbounds = [ib for s, ib in inbounds if s["name"] == srv_name]
if len(srv_inbounds) > 1:
inbound_names = ", ".join([ib["name"] for ib in srv_inbounds])
remark = f"{get_flag_emoji(srv.get('country', ''))} {srv_name.upper()} ({inbound_names})"
else:
remark = f"{get_flag_emoji(srv.get('country', ''))} {srv_name.upper()} ({inbound['name']})" remark = f"{get_flag_emoji(srv.get('country', ''))} {srv_name.upper()} ({inbound['name']})"
all_links.append(f"{clean_link}#{remark}") all_links.append(f"{clean_link}#{remark}")
set_cached_links(subscription_id, all_links) set_cached_links(subscription_id, all_links)