Skip to content

Commit

Permalink
cable-guy: use exact comparison to check if an ip is already assigned
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Jan 14, 2025
1 parent 70614e5 commit c1138a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/services/cable_guy/networksetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ def add_static_ip(self, interface_name: str, ip: str) -> None:
data = settings.get_profile()
if data.connection.interface_name != interface_name:
continue
if any(ip in addressData.address for addressData in data.ipv4.address_data):
logger.info(f"IP {ip} already exists for {interface_name}")
continue

for address_data in data.ipv4.address_data:
if ip == address_data.address:
logger.info(f"IP {ip} already exists for {interface_name}")
return

new_ip = AddressData(address=ip, prefix=24)
data.ipv4.address_data.append(new_ip)
settings.update_profile(data)
Expand Down

0 comments on commit c1138a7

Please sign in to comment.