Skip to content

Conversation

@SUedurable
Copy link

@SUedurable SUedurable commented Nov 30, 2025

This PR solves #219. It probably solves similar issues on other modules with IP:port validation.

I first added tests to prove it didn't work with IPv6 network and IP.
Then implemented the fix.

This patch can surely be improved in some places, especially where duplicating code.
When :port syntax is dropped, this patch can probably be removed.

The new added tests now pass on my fork and I could test locally that it indeed fixes my issue.

Comment on lines 223 to 242

@staticmethod
def is_ipv6_address(address):
""" test if address is a valid ipv6 address """
try:
addr = ip_address(u'{0}'.format(address))
return isinstance(addr, IPv6Address)
except ValueError:
pass
return False

@staticmethod
def is_ipv6_network(address, strict=True):
""" test if address is a valid ipv6 network """
try:
addr = ip_network(u'{0}'.format(address), strict=strict)
return isinstance(addr, IPv6Network)
except ValueError:
pass
return False
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we can surely reference the same (original) functions in pfsense_module but I'm not experienced enough with this project to figure out how.

@opoplawski
Copy link
Contributor

Thanks for the PR. Just a quick note that it's best to create a new branch when working on changes rather than working directly on master.

Do not split on : if parsing ipv6. This also assumes you're not going to
use ipv6:port syntax which is deprecated
Adds tests
Fixes #219
@opoplawski opoplawski merged commit 7d91ba4 into pfsensible:master Nov 30, 2025
4 checks passed
@SUedurable
Copy link
Author

Will do next time :)
Thanks for approving!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants