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

Updated Cloudflare to use token auth and update ttl #1726

Merged
merged 6 commits into from
Jun 13, 2020

Conversation

andreas-rupper
Copy link
Contributor

No description provided.

@andreas-rupper andreas-rupper changed the title Updated Cloudflare to use token auth Updated Cloudflare to use token auth and update ttl Mar 3, 2020
@@ -251,6 +256,15 @@ class updatedns
$this->_error(9);
}
break;
case 'cloudflare-token':
Copy link
Member

Choose a reason for hiding this comment

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

indent seems off

@@ -271,6 +285,7 @@ class updatedns
case 'linode-v6':
case 'regfish-v6':
case 'route53-v6':
case 'cloudflare-token-v6':
Copy link
Member

Choose a reason for hiding this comment

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

indent seems off

@@ -319,6 +334,8 @@ class updatedns
case 'citynetwork':
case 'cloudflare':
case 'cloudflare-v6':
case 'cloudflare-token':
Copy link
Member

Choose a reason for hiding this comment

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

indent

$baseUrl = 'https://api.cloudflare.com/client/v4';
$fqdn = str_replace(' ', '', $this->_dnsHost);
$recordType = ($this->_useIPv6) ? 'AAAA' : 'A';
$ttlData = intval($this->_dnsTTL);
Copy link
Member

Choose a reason for hiding this comment

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

could be simplified (including block below), e.g.

$ttlData = intval($this->_dnsTTL) < 1 ? 1 : intval($this->_dnsTTL);

omitting intval() will likely lead to the same result by the way

"Authorization: Bearer {$this->_dnsPass}",
'Content-Type: application/json'
);
}
Copy link
Member

Choose a reason for hiding this comment

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

@@ -1322,12 +1357,14 @@ class updatedns
break;
case 'cloudflare':
case 'cloudflare-v6':
case 'cloudflare-token':
Copy link
Member

Choose a reason for hiding this comment

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

indent.

@@ -114,6 +114,8 @@ function is_dyndns_username($uname)
switch ($pconfig['type']) {
case 'cloudflare':
case 'cloudflare-v6':
case 'cloudflare-token':
Copy link
Member

Choose a reason for hiding this comment

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

indent

Copy link
Contributor Author

@andreas-rupper andreas-rupper left a comment

Choose a reason for hiding this comment

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

@AdSchellevis Thanks for reviewing.
I have fixed the issues.
If I should have missed smth, please note or correct if necessary ;-)
Thank you 👍 :-)

Copy link
Member

@AdSchellevis AdSchellevis left a comment

Choose a reason for hiding this comment

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

styling looks good now, thanks, only issue left seems to be validating the ttl value.

dns/dyndns/src/www/services_dyndns_edit.php Outdated Show resolved Hide resolved
@AdSchellevis
Copy link
Member

@andreas-rupper looks good to me, just to be sure, did you test the code with correct and faulty inputs? I'm not using the plugin myself, i it works on your end, I'm ok with merging it now.

@andreas-rupper
Copy link
Contributor Author

@andreas-rupper looks good to me, just to be sure, did you test the code with correct and faulty inputs? I'm not using the plugin myself, i it works on your end, I'm ok with merging it now.

@AdSchellevis Yes, I did test it including validation and it worked as expected.
Thanks again for your assistance. (It's my first project on Github...)

@AdSchellevis
Copy link
Member

@andreas-rupper your welcome, thanks for confirming, I'll merge the PR

@AdSchellevis AdSchellevis reopened this Jun 13, 2020
@AdSchellevis AdSchellevis merged commit a391389 into opnsense:master Jun 13, 2020
@@ -139,6 +139,10 @@ function is_dyndns_username($uname)
$input_errors[] = gettext("The username contains invalid characters.");
}

if ((string)((int)$pconfig['ttl']) != $pconfig['ttl']) {
$input_errors[] = gettext("The TTL value needs to be a valid integer number.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Broken. Not all services use this field. Those that don't throw a hissy fit and won't allow to save. e.g. the custom service type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NOYB @AdSchellevis
Please check my pull request #1903 (below)

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.

4 participants