Skip to content
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

dns/bind: allow to specify primaryip's port for secondary zone #4445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Domain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<secondary>secondary</secondary>
</OptionValues>
</type>
<primaryip type="NetworkField">
<FieldSeparator>,</FieldSeparator>
<asList>Y</asList>
<primaryip type="CSVListField">
Copy link
Member

@fichtner fichtner Jan 5, 2025

Choose a reason for hiding this comment

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

As far as I know we have an address/port field type nowadays.

Copy link
Author

Choose a reason for hiding this comment

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

Found a IPPortField field type. This type would require to specify a port and would therefore invalidate address only entries from previous versions...

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it needs to be extended. My point is no more CSV magic regarding this.

Copy link
Author

Choose a reason for hiding this comment

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

I see your point, but I would argue that should be a separate issue/task, requiring changes in core. A quick github search for type="CSVListField" shows matches in three files in core and 29 files in plugins. Can we move this forward in the meantime? Changing it to an extended IPPortField later should be easy enough. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I’m only saying I’m not at the office until tomorrow to do core changes. Copy+paste is not the best idea here in 2025 😊

Copy link
Author

Choose a reason for hiding this comment

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

Any updates on this? By now you must have arrived in the office. 😉

<mask>/^(([0-9a-fA-F.:\[\]]+(:+[0-9])?([,]){0,1}))*/u</mask>
<ValidationMessage>Please provide a valid ip address and optional port, i.e. 192.168.0.33, 10.0.0.99:53530, 2001:0db8:0000:0000:0000:ff00:0042:8329 or [::1]:53530.</ValidationMessage>
</primaryip>
<transferkeyalgo type="OptionField">
<OptionValues>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ zone "{{ domain.domainname }}" {
type {{ domain.type }};
{% if domain.type == 'secondary' %}
{% if domain.transferkey is defined %}
primaries { {{ domain.primaryip.replace(',', ' key "' ~ domain.transferkeyname ~ '"; ') }} key "{{ domain.transferkeyname }}"; };
primaries { {{ domain.primaryip | regex_replace('(?<!:)(?<!:[0-9A-Fa-f]{1})(?<!:[0-9A-Fa-f]{2})(?<!:[0-9A-Fa-f]{3})(?<!:[0-9A-Fa-f]{4}):([0-9]+)((,)|$)', ' port \\1\\2') |
regex_replace ('\[|\]', '') | replace(',', ' key "' ~ domain.transferkeyname ~ '"; ') }} key "{{ domain.transferkeyname }}"; };
{% else %}
primaries { {{ domain.primaryip.replace(',', '; ') }}; };
primaries { {{ domain.primaryip | regex_replace('(?<!:)(?<!:[0-9A-Fa-f]{1})(?<!:[0-9A-Fa-f]{2})(?<!:[0-9A-Fa-f]{3})(?<!:[0-9A-Fa-f]{4}):([0-9]+)((,)|$)', ' port \\1\\2') | regex_replace ('\[|\]', '') | replace(',', '; ') }}; };
{% endif %}
{% if domain.allownotifysecondary is defined %}
allow-notify { {{ domain.allownotifysecondary.replace(',', '; ') }}; };
Expand Down