mod_srvinjection/mod_srvinjection.lua
changeset 1324 853a382c9bd6
parent 1248 69f7840923f5
child 1325 b21236b6b8d8
equal deleted inserted replaced
1323:c84ff82658cb 1324:853a382c9bd6
       
     1 local s = require"util.serialization".new"oneline".serialize;
     1 
     2 
     2 module:set_global();
     3 module:set_global();
     3 
     4 
     4 local adns = require "net.adns";
     5 local adns = require "net.adns";
     5 
     6 
    23 	end
    24 	end
    24 end
    25 end
    25 
    26 
    26 local original_lookup = adns.lookup;
    27 local original_lookup = adns.lookup;
    27 function adns.lookup(handler, qname, qtype, qclass)
    28 function adns.lookup(handler, qname, qtype, qclass)
       
    29 	module:log("debug", "adns.lookup(%s, %s, %s)", s(qname), s(qtype), s(qclass));
    28 	if qtype == "SRV" then
    30 	if qtype == "SRV" then
    29 		local host = qname:match("^_xmpp%-server%._tcp%.(.*)%.$");
    31 		local host = qname:match("^_xmpp%-server%._tcp%.(.*)%.$");
       
    32 		module:log("debug", "qname:match(...) → %s", s(host));
       
    33 		local mapping = map[host] or map["*"];
       
    34 		module:log("debug", "map[%s] → %s", s(host), s(mapping));
    30 		local mapping = map[host] or map["*"];
    35 		local mapping = map[host] or map["*"];
    31 		if mapping then
    36 		if mapping then
    32 			handler(mapping);
    37 			handler(mapping);
    33 			return;
    38 			return;
    34 		end
    39 		end