Skip to content

Commit

Permalink
Flesh out the explanation for ip_address_without_subnet_mask
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchrisadams committed Apr 30, 2024
1 parent 8faceea commit 03f1a8b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/greencheck/importers/network_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ def ip_address_without_subnet_mask(address: str) -> str:
the subnet mask if it was added
"""
# sometimes IP addresses are provided including
# a network prefix, like /24
# We want to remove that
# a network prefix, like 123.123.123.123/24.
# Python rejects these as invalid IP addresses, because
# adding the /24 prefix means this could be any address
# from 123.123.123.0 or 123.123.123.255
#
# We currently assume that if someone is providing a full
# address like this PLUS a prefix, they mean the ip address,
# not the whole network

if "/" in address:
return address.split("/")[0]
Expand Down

0 comments on commit 03f1a8b

Please sign in to comment.