Update modules/visual_route.py
This commit is contained in:
parent
af0b05afdb
commit
dfa4e436c8
1 changed files with 4 additions and 2 deletions
|
|
@ -21,7 +21,6 @@ ROUTER_NAME = os.getenv('BGP_VIS_ROUTER_NAME', 'My Router')
|
||||||
def _bulk_get_as_names(asn_numbers: list[str]):
|
def _bulk_get_as_names(asn_numbers: list[str]):
|
||||||
lookup_list = [asn for asn in asn_numbers if asn not in AS_NAME_CACHE]
|
lookup_list = [asn for asn in asn_numbers if asn not in AS_NAME_CACHE]
|
||||||
if not lookup_list: return
|
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"
|
query = "begin\n" + "\n".join(f"AS{asn}" for asn in lookup_list) + "\nend\n"
|
||||||
try:
|
try:
|
||||||
with socket.create_connection(('bgp.tools', 43), timeout=10) as s:
|
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:]:
|
for line in lines[paths_header_index + 1:]:
|
||||||
stripped_line = line.strip()
|
stripped_line = line.strip()
|
||||||
if not stripped_line: continue
|
if not stripped_line: continue
|
||||||
|
|
||||||
is_new_path_line = False
|
is_new_path_line = False
|
||||||
if line.startswith(' ') and not line.startswith(' '):
|
if line.startswith(' ') and not line.startswith(' '):
|
||||||
first_word = stripped_line.split(' ')[0]
|
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
|
is_new_path_line = True
|
||||||
|
|
||||||
if is_new_path_line:
|
if is_new_path_line:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue