comparison plugins/mod_proxy65.lua @ 9646:eb543e4a47e2

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Mon, 26 Nov 2018 19:48:17 +0100
parents cc642c9c5ad5
children 0f335815244f 65dcc175ef5b
comparison
equal deleted inserted replaced
9641:0ce404230388 9646:eb543e4a47e2
91 91
92 function module.add_host(module) 92 function module.add_host(module)
93 local host, name = module:get_host(), module:get_option_string("name", "SOCKS5 Bytestreams Service"); 93 local host, name = module:get_host(), module:get_option_string("name", "SOCKS5 Bytestreams Service");
94 94
95 local proxy_address = module:get_option_string("proxy65_address", host); 95 local proxy_address = module:get_option_string("proxy65_address", host);
96 local proxy_port = next(portmanager.get_active_services():search("proxy65", nil)[1] or {});
97 local proxy_acl = module:get_option_array("proxy65_acl"); 96 local proxy_acl = module:get_option_array("proxy65_acl");
98 97
99 -- COMPAT w/pre-0.9 where proxy65_port was specified in the components section of the config 98 -- COMPAT w/pre-0.9 where proxy65_port was specified in the components section of the config
100 local legacy_config = module:get_option_number("proxy65_port"); 99 local legacy_config = module:get_option_number("proxy65_port");
101 if legacy_config then 100 if legacy_config then
118 if jid_compare(jid, acl) then allow = true; break; end 117 if jid_compare(jid, acl) then allow = true; break; end
119 end 118 end
120 if allow then break; end 119 if allow then break; end
121 module:log("warn", "Denying use of proxy for %s", tostring(stanza.attr.from)); 120 module:log("warn", "Denying use of proxy for %s", tostring(stanza.attr.from));
122 origin.send(st.error_reply(stanza, "auth", "forbidden")); 121 origin.send(st.error_reply(stanza, "auth", "forbidden"));
122 return true;
123 end
124
125 local proxy_port = next(portmanager.get_active_services():search("proxy65", nil)[1] or {});
126 if not proxy_port then
127 module:log("warn", "Not listening on any port");
128 origin.send(st.error_reply(stanza, "wait", "item-not-found", "Not listening on any port"));
123 return true; 129 return true;
124 end 130 end
125 131
126 local sid = stanza.tags[1].attr.sid; 132 local sid = stanza.tags[1].attr.sid;
127 origin.send(st.reply(stanza):tag("query", {xmlns="http://jabber.org/protocol/bytestreams", sid=sid}) 133 origin.send(st.reply(stanza):tag("query", {xmlns="http://jabber.org/protocol/bytestreams", sid=sid})