Skip to content

Commit

Permalink
改进解析sing-box格式
Browse files Browse the repository at this point in the history
  • Loading branch information
Toperlock authored Nov 7, 2023
1 parent b92ec25 commit 3356437
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,11 @@ def get_nodes(url):
processed_list.append(item)
return processed_list
elif 'outbounds' in content:
outbounds_0 = content['outbounds'][0]['outbounds']
outbounds_tags = [item["tag"] for item in content["outbounds"][1:]]
matching_tags = [tag for tag in outbounds_tags if tag in outbounds_0]
filtered_tags = [tag for tag in matching_tags if tag not in ["auto", "direct"]]
matching_indices = []
for i, outbound in enumerate(content["outbounds"][1:]):
if outbound["tag"] in filtered_tags:
matching_indices.append(i + 1) # 添加1以补偿切片的偏移
data = [content["outbounds"][i] for i in matching_indices]
return data
outbounds = []
excluded_types = {"selector", "urltest", "direct", "block", "dns"}
filtered_outbounds = [outbound for outbound in content['outbounds'] if outbound.get("type") not in excluded_types]
outbounds.extend(filtered_outbounds)
return outbounds
else:
data = parse_content(content)
processed_list = []
Expand Down

0 comments on commit 3356437

Please sign in to comment.