Runtime-modifiable IP address sets

New in version 1.2.0.

From within maintenance() or other places, we may find that certain IP addresses must be treated differently for a certain time.

This may be used to temporarily shunt traffic to another pool for example.

TimedIPSetRule() creates an object to which native IP addresses can be added in ComboAddress form.

TimedIPSetRule() → TimedIPSetRule

Returns a TimedIPSetRule.

class TimedIPSetRule

Can be used to handle IP addresses differentlt based on the date and time

classmethod TimedIPSetRule:add(address, seconds)

Add an IP address to the set for the next second seconds.

  • address (ComboAddress) – The address to add
  • seconds (int) – Time to keep the address in the Rule
classmethod TimedIPSetRule:cleanup()

Purge the set from expired IP addresses

classmethod TimedIPSetRule:clear()

Clear the entire set

classmethod TimedIPSetRule:slice()

Convert the TimedIPSetRule into a DNSRule that can be passed to addAction()

A working example:

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


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

addLuaAction(AllRule(), pickPool)