Skip to content

Commit 32c0f76

Browse files
committed
clean up parsing
1 parent c4e42c9 commit 32c0f76

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

netsim/main.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ def parse_node_params(node, prefix, node_params, runner_id):
6565
node_params[node_name] = lines[idx + 1].strip()
6666
break
6767
if node["param_parser"] == "iroh_endpoint_with_addrs":
68-
# Handle both "Our endpoint id:" (from bind_endpoint) and "Endpoint id:" (from provide)
69-
if line.startswith("Our endpoint id:"):
68+
# Look for "Endpoint id:" followed by direct addresses
69+
if line.startswith("Endpoint id:"):
7070
if idx + 1 >= len(lines):
7171
break
7272
endpoint_id = lines[idx + 1].strip()
7373
direct_addrs = []
74+
# Look for "Direct addresses:" after the endpoint ID
7475
j = idx + 2
75-
if j < len(lines) and lines[j].startswith("Our direct addresses:"):
76+
if j < len(lines) and lines[j].startswith("Direct addresses:"):
7677
j += 1
7778
while j < len(lines) and lines[j].startswith("\t"):
7879
direct_addrs.append(lines[j].strip())
@@ -82,28 +83,6 @@ def parse_node_params(node, prefix, node_params, runner_id):
8283
"direct_addrs": direct_addrs
8384
}
8485
break
85-
elif line.startswith("Endpoint id:") and node_name not in node_params:
86-
# Fallback for simple "Endpoint id:" output (no "Our")
87-
# Format: "Endpoint id:\n<id>\n"
88-
if idx + 1 < len(lines):
89-
endpoint_id = lines[idx + 1].strip()
90-
# Try to find direct addresses from debug logs
91-
direct_addrs = []
92-
# Look backwards and forwards for direct_addrs debug line
93-
for search_idx in range(max(0, idx - 20), min(len(lines), idx + 20)):
94-
search_line = lines[search_idx]
95-
if "direct_addrs:" in search_line and "DirectAddr" in search_line:
96-
# Extract address from: addrs={DirectAddr { addr: 10.0.0.2:47103, typ: Local }}
97-
import re
98-
match = re.search(r'addr:\s*([0-9.]+:\d+)', search_line)
99-
if match:
100-
direct_addrs.append(match.group(1))
101-
break
102-
node_params[node_name] = {
103-
"endpoint_id": endpoint_id,
104-
"direct_addrs": direct_addrs
105-
}
106-
break
10786
return node_params
10887

10988

0 commit comments

Comments
 (0)