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

RFC2136 RecordType Option #1457

Merged
merged 8 commits into from Mar 10, 2017
Merged

RFC2136 RecordType Option #1457

merged 8 commits into from Mar 10, 2017

Conversation

ghost
Copy link

@ghost ghost commented Mar 9, 2017

As explained in #1456 this PR makes it possible to control whether A, AAAA or both record types are changed when updating using RFC2136.

Tasks

  • Modify edit page
  • Modify service function
  • Modify table overview

Open Questions

pfSense do not changed their table overview template, so you cannot see which record types are updated. Should we add this in OPNsense as it might be useful because you do not have to open the edit page for each update task? (see discussion)

@ghost
Copy link
Author

ghost commented Mar 9, 2017

I will try to change the overview of all RFC2136 update tasks!

@fichtner fichtner self-assigned this Mar 9, 2017
@ghost
Copy link
Author

ghost commented Mar 9, 2017

One should keep it as simple as possible. In order to follow this idea I have added an extra check so only ip address types which should be updated are displayed in the overview table.

@@ -58,6 +58,9 @@
$pconfig['usetcp'] = isset($a_rfc2136[$id]['usetcp']);
$pconfig['usepublicip'] = isset($a_rfc2136[$id]['usepublicip']);

$pconfig['recordtype'] = $a_rfc2136[$id]['recordtype'];
if (!$pconfig['recordtype']) $pconfig['recordtype'] = "both";
Copy link
Member

Choose a reason for hiding this comment

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

For compatibility the record type should remain empty in the case of "both".

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, if I did not get the point but if there is no recordtype set, you are currently updating A and AAAA records which is reflected by "both".

Copy link
Member

Choose a reason for hiding this comment

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

yes. the config semantics are changed here so this imposes a silent migration only when the entry is edited. we cannot guarantee this won't be problematic in the future so we need to keep the empty value as default. :)

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I will change it! :)

Copy link
Member

Choose a reason for hiding this comment

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

Cool. If you need anything or have questions I'm happy to help. :)

Copy link
Author

Choose a reason for hiding this comment

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

@fichtner I want to test my changes but there is a problem: opnsense/tools#46

Copy link
Member

Choose a reason for hiding this comment

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

From a working OPNsense VM you can install the repository and upgrade from there:

# opnsense-code -a wevcode opnsense-core
# cd /usr/opnsense-core
# git checkout rfc2136-recordtype-option
# opnsense-update -t opnsense-devel
# make upgrade

Copy link
Author

Choose a reason for hiding this comment

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

@fichtner I cannot find this in the tools repository as a documentation, please add this tip for other contributors.

Copy link
Member

Choose a reason for hiding this comment

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

Most of it is in the handbook: https://docs.opnsense.org/development/workflow.html

But it needs some updates on the refined tools :)

<td class="vtable">
<input name="recordtype" type="radio" value="A" <?php if ($pconfig['recordtype'] == "A") echo "checked=\"checked\""; ?> /> <?=gettext("A (IPv4)");?> &nbsp;
<input name="recordtype" type="radio" value="AAAA" <?php if ($pconfig['recordtype'] == "AAAA") echo "checked=\"checked\""; ?> /> <?=gettext("AAAA (IPv6)");?> &nbsp;
<input name="recordtype" type="radio" value="both" <?php if ($pconfig['recordtype'] == "both") echo "checked=\"checked\""; ?> /> <?=gettext("Both");?>
Copy link
Member

Choose a reason for hiding this comment

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

value="" and empty($pconfig['recordtype']) is better, also the default selection should be the first in the list.

Copy link
Author

Choose a reason for hiding this comment

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

I will remove the "values", for the second change please read my comment above.

@@ -1748,7 +1748,7 @@ EOD;
$need_update = false;

/* Update IPv4 if we have it. */
if (is_ipaddrv4($wanip)) {
if (is_ipaddrv4($wanip) && $dnsupdate['recordtype'] != "AAAA") {
Copy link
Member

Choose a reason for hiding this comment

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

logic works, but may not be resilient against broadening recordtype to other types, maybe:

is_ipaddrv4($wanip) && (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'A')

Copy link
Author

Choose a reason for hiding this comment

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

Well I see yout point. Do you think, we should rename "both" to "ALL" which represents all normal DNS records as A, AAAA (and maybe AAAAAAAA in some years)?

Any other record type has to be set by an extra configuration option as MX, right?

Copy link
Member

Choose a reason for hiding this comment

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

That's the idea, exactly. And indeed "All" sounds best for future use.

@fichtner
Copy link
Member

fichtner commented Mar 9, 2017

And BTW: thanks for working on this 👍

@ghost
Copy link
Author

ghost commented Mar 9, 2017

OpenSource: Everyone can use it, but you should also try to give something back! 👍

In order to provide support for additional recorytypes,
'both' is changed to 'all', which is represented by an empty value.
To provide support for additional recordtypes all checks had to be
changed.
@ghost
Copy link
Author

ghost commented Mar 10, 2017

@fichtner Updated branch; I will test it now. 🏁

@@ -58,6 +58,8 @@
$pconfig['usetcp'] = isset($a_rfc2136[$id]['usetcp']);
$pconfig['usepublicip'] = isset($a_rfc2136[$id]['usepublicip']);

$pconfig['recordtype'] = $a_rfc2136[$id]['recordtype'];
Copy link
Member

Choose a reason for hiding this comment

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

This needs something like:

$pconfig['server'] = isset($id) &&!empty($a_rfc2136[$id]['server']) ? $a_rfc2136[$id]['server'] : null;

Copy link
Author

Choose a reason for hiding this comment

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

You are right, I will change it!

@@ -140,7 +140,7 @@
<td>
<?php
$filename = "/conf/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
if (file_exists($filename) && !empty($rfc2136['enable'])) {
if (file_exists($filename) && !empty($rfc2136['enable']) && $rfc2136['recordtype'] != "AAAA") {
Copy link
Member

Choose a reason for hiding this comment

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

same logic as in services.inc should be used here. We cannot expect it to be set, it would probably produce a warning now.

Copy link
Author

Choose a reason for hiding this comment

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

Missed that, sorry.

@ghost
Copy link
Author

ghost commented Mar 10, 2017

@fichtner Should be fixed! :)

@ghost
Copy link
Author

ghost commented Mar 10, 2017

@fichtner Also added a help text to undestand the new 'all' option.

@ghost
Copy link
Author

ghost commented Mar 10, 2017

Ready for review.

@fichtner fichtner merged commit fb7c461 into opnsense:master Mar 10, 2017
@fichtner
Copy link
Member

Merged, thanks!

fichtner added a commit that referenced this pull request Mar 10, 2017
@fichtner
Copy link
Member

Two small follow-ups committed. I think this will land in 17.1.3 next week. Thanks again.

fichtner added a commit that referenced this pull request Mar 10, 2017
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.

2 participants