]> granicus.if.org Git - pdns/commit
Implement a runtime changeable rule that matches IP address for a certain time.
authorbert hubert <bert.hubert@netherlabs.nl>
Mon, 22 May 2017 20:59:11 +0000 (22:59 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 21 Jun 2017 12:27:35 +0000 (14:27 +0200)
commit2b58b6257e08695600cb31c1f3763d0fb924a329
tree547a641899d220d921ee156f20efe244275302e3
parent2db723203019b3e2731599d295136c7119fdd776
Implement a runtime changeable rule that matches IP address for a certain time.
This effectively allows (for example) pool selection from Lua, but then cached.

Sample code:

```
newServer({address="192.168.1.20", pool=""})
newServer({address="8.8.8.8", pool="elgoog"})

tisrElGoog=TimedIPSetRule()
tisrRest=TimedIPSetRule()
addAction(tisrElGoog:slice(), PoolAction("elgoog"))
addAction(tisrRest:slice(), PoolAction(""))

elgoogPeople=newNMG()
elgoogPeople:addMask("192.168.1.0/28")

function pickPool(dq)
if(elgoogPeople:match(dq.remoteaddr)) -- in real life, this would be external
then
print("Lua caught query for a googlePerson")
tisrElGoog:add(dq.remoteaddr, 10)
return DNSAction.Pool, "elgoog"
else
print("Lua caught query for restPerson")
tisrRest:add(dq.remoteaddr, 60)
return DNSAction.None, ""
end
end

addLuaAction(AllRule(), pickPool)
```
pdns/dnsdist-lua2.cc
pdns/dnsrulactions.hh