Skip to content

Kea static route GUI validation #8742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

meyergru
Copy link
Contributor

This implements #8738.

I know a regex is ugly, yet I have found no easy way to use NetworkField, because the list may only contain pairs of destination/router ips. Otherwise, clients will reject the whole DHCP offer.

meyergru added 2 commits May 30, 2025 11:11
This implements opnsense#8738.

I know it is ugly, yet I have found no easy way to use NetworkField, because the list may only contain an even number of IPv4s.

Otherwise, clients will reject the whole DHCP response.
@Monviech
Copy link
Member

@meyergru
Copy link
Contributor Author

I will try that later. Question: Do I need to / can I transform the output? In this case, it would be better if the single elements would be specified like 0.0.0.0,1.2.3.4 and grouped like in a NetworkField, but the output has to concatenate them together, separated by commas.

BTW: The "Unifi" option is a similar case where an IP must be transformed to a binary string.

meyergru added 4 commits May 30, 2025 14:56
Change to specific KeaRoutesField
Add specific KeaRoutesField type
Output separate lines as one comma-separated line
Change help text for new type
@meyergru
Copy link
Contributor Author

meyergru commented May 30, 2025

@Monviech: I think this works now - at least for me, it does.

I have not really looked at migrations (if people specified multiple routes earlier, they must edit the input manually) and I found nothing in the API as a blueprint for this, either. I think that the API code misses the options altogether, right?

Copy link
Member

@Monviech Monviech left a comment

Choose a reason for hiding this comment

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

This is all I can add, custom field types are more in @AdSchellevis domain.

if (empty($entry)) {
continue;
} elseif (count($parts) == 2 && Util::isIpAddress($parts[0]) && Util::
isIpAddress($parts[1])) {
Copy link
Member

Choose a reason for hiding this comment

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

this line break is weird

continue;
}
$messages[] = sprintf(gettext('Entry "%s" is not a valid dest-ip,route
r-ip pair.'), $entry);
Copy link
Member

Choose a reason for hiding this comment

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

this line break is weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. Copy&paste error. Fixed.

Sorry, copy-paste error w/r to line breaks.
@AdSchellevis
Copy link
Member

@meyergru I've slightly simplified it in 28f6a5f, which ignores whitespaces when entered. Thanks!

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

Successfully merging this pull request may close these issues.

3 participants