From 0771b300e545c109bce1a0d1ce59ed1f0f854f4f Mon Sep 17 00:00:00 2001 From: SashegDev Date: Wed, 20 May 2026 16:54:03 +0000 Subject: [PATCH] fix: match links to inbounds by index instead of grouping all inbound names --- aggregator.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/aggregator.py b/aggregator.py index 5a90385..a34f8c5 100644 --- a/aggregator.py +++ b/aggregator.py @@ -417,32 +417,35 @@ async def get_subscription(request: Request, subscription_id: str, format: str = all_links = [] seen_links = set() servers_processed = set() + server_links = {} for srv, inbound in inbounds: srv_name = srv["name"] - if srv_name in servers_processed: + + if srv_name not in servers_processed: + servers_processed.add(srv_name) + sub_path = srv["sub_path"].format(sub_id=subscription_id) + url = f"{srv['subscription_url'].rstrip('/')}{sub_path}" + server_links[srv_name] = await fetch_vless_links(url) + + 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 - sub_path = srv["sub_path"].format(sub_id=subscription_id) - url = f"{srv['subscription_url'].rstrip('/')}{sub_path}" - links = await fetch_vless_links(url) + if link_idx >= len(links): + continue - servers_processed.add(srv_name) + link = links[link_idx] + clean_link = link.split('#')[0] + if clean_link in seen_links: + continue + seen_links.add(clean_link) - for link in links: - clean_link = link.split('#')[0] - if clean_link in seen_links: - continue - 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']})" - - all_links.append(f"{clean_link}#{remark}") + remark = f"{get_flag_emoji(srv.get('country', ''))} {srv_name.upper()} ({inbound['name']})" + all_links.append(f"{clean_link}#{remark}") set_cached_links(subscription_id, all_links)