comparison mod_seclabels/mod_seclabels.lua @ 451:f43d2d26c1c4

mod_seclabels: Fix config reloading
author Kim Alvefur <zash@zash.se>
date Wed, 05 Oct 2011 23:54:33 +0200
parents fb152d4af082
children 48b615229509
comparison
equal deleted inserted replaced
450:fb152d4af082 451:f43d2d26c1c4
19 SECRET = { color = "black", bgcolor = "aqua", label = "THISISSECRET" }; 19 SECRET = { color = "black", bgcolor = "aqua", label = "THISISSECRET" };
20 PUBLIC = { label = "THISISPUBLIC" }; 20 PUBLIC = { label = "THISISPUBLIC" };
21 }; 21 };
22 }; 22 };
23 local catalog_name, catalog_desc, labels; 23 local catalog_name, catalog_desc, labels;
24 function get_conf() 24 local function get_conf()
25 catalog_name = module:get_option_string("security_catalog_name", "Default"); 25 catalog_name = module:get_option_string("security_catalog_name", "Default");
26 catalog_desc = module:get_option_string("security_catalog_desc", "My labels"); 26 catalog_desc = module:get_option_string("security_catalog_desc", "My labels");
27 labels = module:get_option("security_labels", default_labels); 27 labels = module:get_option("security_labels", default_labels);
28 end 28 end
29 module:hook("config-reloaded",get_conf); 29 module:hook_global("config-reloaded",get_conf);
30 get_conf(); 30 get_conf();
31 31
32 function handle_catalog_request(request) 32 function handle_catalog_request(request)
33 local catalog_request = request.stanza.tags[1]; 33 local catalog_request = request.stanza.tags[1];
34 local reply = st.reply(request.stanza) 34 local reply = st.reply(request.stanza)
72 else 72 else
73 add_labels(catalog, value, (selector or "")..name.."|"); 73 add_labels(catalog, value, (selector or "")..name.."|");
74 end 74 end
75 end 75 end
76 end 76 end
77 -- TODO query remote servers
78 --[[ FIXME later
79 labels = module:fire_event("sec-label-catalog", {
80 to = catalog_request.attr.to,
81 request = request; -- or just origin?
82 labels = labels;
83 }) or labels;
84 --]]
77 add_labels(reply, labels, ""); 85 add_labels(reply, labels, "");
78 request.origin.send(reply); 86 request.origin.send(reply);
79 return true; 87 return true;
80 end 88 end
81 module:hook("iq/host/"..xmlns_label_catalog..":catalog", handle_catalog_request); 89 module:hook("iq/host/"..xmlns_label_catalog..":catalog", handle_catalog_request);