Skip to content

Commit

Permalink
use ipaddress
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Litvinenko authored and GeorgyKirichenko committed Oct 3, 2024
1 parent 9459d23 commit 16a5443
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions yanet-announcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import signal
import subprocess
import ipaddress
import textwrap
import time
import typing
Expand Down Expand Up @@ -149,7 +150,8 @@ def bgp_remove_ipv6(prefix):
def bgp_update(prefix_list):
for prefix in prefix_list:
try:
if ":" in prefix:
parsed = ipaddress.ip_network(prefix)
if parsed.version == 6:
bgp_update_ipv6(prefix)
else:
bgp_update_ipv4(prefix)
Expand All @@ -160,7 +162,8 @@ def bgp_update(prefix_list):
def bgp_remove(prefix_list):
for prefix in prefix_list:
try:
if ":" in prefix:
parsed = ipaddress.ip_network(prefix)
if parsed.version == 6:
bgp_remove_ipv6(prefix)
else:
bgp_remove_ipv4(prefix)
Expand Down

0 comments on commit 16a5443

Please sign in to comment.