PowerDNS / pdns

PowerDNS Authoritative, PowerDNS Recursor, dnsdist
https://www.powerdns.com/
GNU General Public License v2.0
3.63k stars 904 forks source link

Lua - have netmaskgroup:match return netmask that matched #2264

Open nielspeen opened 9 years ago

nielspeen commented 9 years ago

On Thu, Feb 19, 2015 at 05:40:47PM +0100, Niels Peen wrote: Hello, I’m using a netmaskgroup to see if a given IP matches:

if nmg:match(ca) then ..

This works very well but I would like to know which specific netmask matched. E.g. by having :match (also) return the matching netmask rather than (just) returning true.

Am I correct that this is currently not possible? If so, could this be considered for a future release?

Hi Niels,

This is currently not possible, but it sounds like a great idea.

It may be good to know that the netmaskgroup currently just tries all netmasks to see if one fits, you could easily emulate this in Lua itself, and it would not be slower. And then you would know which address matched.

Could you open a ticket requesting this feature on github? Please put a note in there we find it a fine idea.

Bert

Habbie commented 7 years ago

NMG no longer just 'tries all addresses', the new code might make this feature a lot easier to implement.

jesysop commented 2 years ago

+1

I would like to identify the matching Netmask so that I can use the additional information in the reply.

In my case, this information is being used elsewhere to update a firewall rule, where it would be more convenient to match an entire mask rather than a single IP

Additionally, there does not appear to be an easy way to read the NetMasksGroup object to review the existing masks