Comparison

plugins/mod_register.lua @ 1712:45a81d6d8777

Merge waqas with Tobias. Eww.
author Matthew Wild <mwild1@gmail.com>
date Tue, 18 Aug 2009 13:03:35 +0100
parent 1692:be76bac8e174
child 1861:e9500c4994f3
comparison
equal deleted inserted replaced
1686:232c2bf155c7 1712:45a81d6d8777
7 -- 7 --
8 8
9 9
10 local hosts = _G.hosts; 10 local hosts = _G.hosts;
11 local st = require "util.stanza"; 11 local st = require "util.stanza";
12 local config = require "core.configmanager";
13 local datamanager = require "util.datamanager"; 12 local datamanager = require "util.datamanager";
14 local usermanager_user_exists = require "core.usermanager".user_exists; 13 local usermanager_user_exists = require "core.usermanager".user_exists;
15 local usermanager_create_user = require "core.usermanager".create_user; 14 local usermanager_create_user = require "core.usermanager".create_user;
16 local datamanager_store = require "util.datamanager".store; 15 local datamanager_store = require "util.datamanager".store;
17 local os_time = os.time; 16 local os_time = os.time;
88 session.send(st.error_reply(stanza, "cancel", "service-unavailable")); 87 session.send(st.error_reply(stanza, "cancel", "service-unavailable"));
89 end; 88 end;
90 end); 89 end);
91 90
92 local recent_ips = {}; 91 local recent_ips = {};
93 local min_seconds_between_registrations = config.get(module.host, "core", "min_seconds_between_registrations"); 92 local min_seconds_between_registrations = module:get_option("min_seconds_between_registrations");
94 local whitelist_only = config.get(module.host, "core", "whitelist_registration_only"); 93 local whitelist_only = module:get_option("whitelist_registration_only");
95 local whitelisted_ips = config.get(module.host, "core", "registration_whitelist") or { "127.0.0.1" }; 94 local whitelisted_ips = module:get_option("registration_whitelist") or { "127.0.0.1" };
96 local blacklisted_ips = config.get(module.host, "core", "registration_blacklist") or {}; 95 local blacklisted_ips = module:get_option("registration_blacklist") or {};
97 96
98 for _, ip in ipairs(whitelisted_ips) do whitelisted_ips[ip] = true; end 97 for _, ip in ipairs(whitelisted_ips) do whitelisted_ips[ip] = true; end
99 for _, ip in ipairs(blacklisted_ips) do blacklisted_ips[ip] = true; end 98 for _, ip in ipairs(blacklisted_ips) do blacklisted_ips[ip] = true; end
100 99
101 module:add_iq_handler("c2s_unauthed", "jabber:iq:register", function (session, stanza) 100 module:add_iq_handler("c2s_unauthed", "jabber:iq:register", function (session, stanza)
102 if config.get(module.host, "core", "allow_registration") == false then 101 if module:get_option("allow_registration") == false then
103 session.send(st.error_reply(stanza, "cancel", "service-unavailable")); 102 session.send(st.error_reply(stanza, "cancel", "service-unavailable"));
104 elseif stanza.tags[1].name == "query" then 103 elseif stanza.tags[1].name == "query" then
105 local query = stanza.tags[1]; 104 local query = stanza.tags[1];
106 if stanza.attr.type == "get" then 105 if stanza.attr.type == "get" then
107 local reply = st.reply(stanza); 106 local reply = st.reply(stanza);