Update modules/visual_route.py

This commit is contained in:
Blackwhitebear8 2025-08-13 18:28:57 +02:00
parent af0b05afdb
commit dfa4e436c8

View file

@ -21,7 +21,6 @@ ROUTER_NAME = os.getenv('BGP_VIS_ROUTER_NAME', 'My Router')
def _bulk_get_as_names(asn_numbers: list[str]):
lookup_list = [asn for asn in asn_numbers if asn not in AS_NAME_CACHE]
if not lookup_list: return
print(f"Performing bulk lookup for {len(lookup_list)} AS numbers...")
query = "begin\n" + "\n".join(f"AS{asn}" for asn in lookup_list) + "\nend\n"
try:
with socket.create_connection(('bgp.tools', 43), timeout=10) as s:
@ -67,10 +66,13 @@ def _parse_bgp_paths_to_graph(bgp_data: str) -> dict:
for line in lines[paths_header_index + 1:]:
stripped_line = line.strip()
if not stripped_line: continue
is_new_path_line = False
if line.startswith(' ') and not line.startswith(' '):
first_word = stripped_line.split(' ')[0]
if first_word.isdigit() or stripped_line == "Local":
cleaned_first_word = first_word.replace(',', '')
if cleaned_first_word.isdigit() or stripped_line == "Local":
is_new_path_line = True
if is_new_path_line: