fix: match links to inbounds by index instead of grouping all inbound names
This commit is contained in:
+22
-19
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user