geoip.lua

changeset 21
3a89f5722626
parent 20
fed4cf6b1f43
child 22
67c2b47a00c7
equal deleted inserted replaced
20:fed4cf6b1f43 21:3a89f5722626
12 log("debug", "Loaded geoip database successfully"); 12 log("debug", "Loaded geoip database successfully");
13 13
14 events.add_handler("new-client", function (info) 14 events.add_handler("new-client", function (info)
15 local ip = info.conn:ip(); 15 local ip = info.conn:ip();
16 local location = city_db:query_by_addr(ip); 16 local location = city_db:query_by_addr(ip);
17 log("debug", "GeoIP query for %s", tostring(ip));
18 local location, err = city_db:query_by_addr(ip);
17 if location then 19 if location then
18 local l = {}; 20 local l = {};
19 if location.city_name then 21 if location.city_name then
20 table.insert(l, location.city_name); 22 table.insert(l, location.city_name);
21 end 23 end

mercurial