abbaac9520
Co-authored-by: Cursor <cursoragent@cursor.com>
17 lines
469 B
Python
17 lines
469 B
Python
"""节点端口与 inbound 标签(多节点统计用)。"""
|
|
|
|
|
|
def ordered_nodes(nodes: list[dict]) -> list[dict]:
|
|
return sorted(nodes, key=lambda n: int(n["id"]))
|
|
|
|
|
|
def hy2_port(node: dict, nodes: list[dict], base: int = 8443) -> int:
|
|
for index, item in enumerate(ordered_nodes(nodes)):
|
|
if int(item["id"]) == int(node["id"]):
|
|
return base + index
|
|
return base
|
|
|
|
|
|
def hy2_inbound_tag(node_id: int) -> str:
|
|
return f"hy2-in-{node_id}"
|