php-dns icon indicating copy to clipboard operation
php-dns copied to clipboard

Add 3rd parameter to getRecords to optionally skip filtering records

Open xorinzor opened this issue 1 year ago • 3 comments

Fix for #53

Adds a 3rd parameter to getRecords to optionally skip filtering records. Backwards compatible with the original code.

This allows a lookup for any kind of record type (for example TXT) to also return CNAME records. This is consistent with how dig also returns records.

xorinzor avatar Aug 19 '23 13:08 xorinzor

I will take a look at this and the issue tonight, thanks for submitting!

remotelyliving avatar Aug 21 '23 17:08 remotelyliving

Turns out this doesn't work for RemotelyLiving\PHPDNS\Resolvers\Dig since that class appears to filter records before returning them regardless. That resolver class would require (breaking) rework in order to just return the record-set from the lookup.

Currently Dig is incapable of returning the full record-set unless the ANY type is provided (in which case it'll also query all types individually).

The CloudFlare resolver however works different, as it does return the full record set and doesn't get filtered by type within the class itself. Arguably this is the correct way for resolvers to work as you'd want to manage the filtering within your application, as well as the fact that Dig is in it's current form incapable of returning the actual results as the command dig would.

I do think my PR still adds value, but I thought it'd be important to mention this.

xorinzor avatar Aug 22 '23 07:08 xorinzor

@remotelyliving did you have a chance to look at this yet?

xorinzor avatar Aug 31 '23 14:08 xorinzor