1 local adns = require "net.adns"; |
1 local adns = require "net.adns"; |
2 local async = require "util.async"; |
2 local async = require "util.async"; |
3 local inet_pton = require "util.net".pton; |
3 local inet_pton = require "util.net".pton; |
|
4 local to_hex = require "util.hex".to; |
4 |
5 |
5 local rbl = module:get_option_string("registration_rbl"); |
6 local rbl = module:get_option_string("registration_rbl"); |
6 |
7 |
7 local function reverse(ip, suffix) |
8 local function reverse(ip, suffix) |
8 local n, err = inet_pton(ip); |
9 local n, err = inet_pton(ip); |
9 if not n then return n, err end |
10 if not n then return n, err end |
10 if #n == 4 then |
11 if #n == 4 then |
11 local a,b,c,d = n:byte(1,4); |
12 local a,b,c,d = n:byte(1,4); |
12 return ("%d.%d.%d.%d.%s"):format(d,c,b,a, suffix); |
13 return ("%d.%d.%d.%d.%s"):format(d,c,b,a, suffix); |
|
14 elseif #n == 16 then |
|
15 return to_hex(n):reverse():gsub("%x", "%1.") .. suffix; |
13 end |
16 end |
14 end |
17 end |
15 |
18 |
16 module:hook("user-registering", function (event) |
19 module:hook("user-registering", function (event) |
17 local session, ip = event.session, event.ip; |
20 local session, ip = event.session, event.ip; |