comparison mod_register_dnsbl/mod_register_dnsbl.lua @ 2115:2ae5286f1b9a

Merge
author Matthew Wild <mwild1@gmail.com>
date Thu, 17 Mar 2016 12:11:12 +0000
parents 0890c4860f14
children 42b095dab626
comparison
equal deleted inserted replaced
2114:ce3dd93f30d9 2115:2ae5286f1b9a
1 local adns = require "net.adns";
2 local rbl = module:get_option_string("registration_rbl");
3
4 local function reverse(ip, suffix)
5 local a,b,c,d = ip:match("^(%d+%).(%d+%).(%d+%).(%d+%)$");
6 if not a then return end
7 return ("%d.%d.%d.%d.%s"):format(d,c,b,a, suffix);
8 end
9
10 -- TODO async
11 -- module:hook("user-registering", function (event) end);
12
13 module:hook("user-registered", function (event)
14 local session = event.session;
15 local ip = session and session.ip;
16 local rbl_ip = ip and reverse(ip, rbl);
17 if rbl_ip then
18 local log = session.log;
19 adns.lookup(function (reply)
20 if reply and reply[1] then
21 log("warn", "Registration from IP %s found in RBL", ip);
22 end
23 end, rbl_ip);
24 end
25 end);