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 Validation Issue #249

Closed
BenHarris opened this issue Jul 9, 2020 · 3 comments
Closed

DNS Validation Issue #249

BenHarris opened this issue Jul 9, 2020 · 3 comments
Projects

Comments

@BenHarris
Copy link
Contributor

BenHarris commented Jul 9, 2020

I hit an issue today where the DNS validation wasn't working. It looks like there is a bug in alpine Linux (I was using the php:7.4-fpm-alpine docker image), which means checkdnsrr returns true even if the domain doesn't exist. See the bug reports below:

Whilst I appreciate this is not a bug in this library, I wonder if it might be worth switching to dns_get_record in DNSCheckValidation instead, which is unaffected, allows us the same validation and was also somewhat faster in my tests.

dns_get_record returns an array or false, so the equivalent implementation would just be to do something like $MXresult = !empty(dns_get_record($host, DNS_MX));

Invalid domain test

Function Result Runtime
checkdnsrr('notavaliddomain.c2.', 'MX') bool(false) 0.00630
dns_get_record('notavaliddomain.d2.', DNS_MX) array(0){} 0.00497

Valid domain

Function Result Runtime
checkdnsrr('google.com.', 'MX') bool(true) 0.00152
dns_get_record('google.com.', DNS_MX)
array(5) {
[0]=> array(6) {
["host"]=> string(10) "google.com"
["class"]=> string(2) "IN"
["ttl"]=> int(600)
["type"]=> string(2) "MX"
["pri"]=> int(40)
["target"]=> string(23) "alt3.aspmx.l.google.com"
}
...
}
0.00115
@BenHarris
Copy link
Contributor Author

Another benefit to this approach would be handling the "Null MX" case RFC 7505.

checkdnsrr('example.com.', 'MX') returns bool(true) as the MX record exists. As there is no target, it should be considered invalid and return false. dns_get_record() returns the DNS records, so we can simply validate that a) there is an MX record and b) it is a valid record.

@egulias
Copy link
Owner

egulias commented Jul 20, 2020

Hi @BenHarris ,
Thanks for informing about this issue.
I see the benefits you state and i'd be a great improvement for that validation.
I encourage you to do the change and send a PR ;), I will be more than happy to review and merge.

Looking forward to that PR!

@egulias egulias added this to To do in V3 via automation Jul 20, 2020
@egulias
Copy link
Owner

egulias commented Jul 20, 2020

I'll do the port to V3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
V3
  
Done
Development

No branches or pull requests

2 participants