I have a TODO to implement `ipmatch` which would be useful here.  Let me know if I should implement it or if this is good enough for you.