Software /
code /
prosody
Comparison
plugins/mod_proxy65.lua @ 2249:6e0c861dc61f
mod_proxy65: Use new jid.join() from util.jid
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 27 Nov 2009 18:02:24 +0000 |
parent | 2244:730038d3e9e3 |
child | 2272:9c3564117b24 |
comparison
equal
deleted
inserted
replaced
2248:37344b18b551 | 2249:6e0c861dc61f |
---|---|
12 | 12 |
13 if module:get_host_type() ~= "component" then | 13 if module:get_host_type() ~= "component" then |
14 error("proxy65 should be loaded as a component, please see http://prosody.im/doc/components", 0); | 14 error("proxy65 should be loaded as a component, please see http://prosody.im/doc/components", 0); |
15 end | 15 end |
16 | 16 |
17 local jid_split = require "util.jid".split; | 17 local jid_split, jid_join = require "util.jid".split, require "util.jid".join; |
18 local st = require "util.stanza"; | 18 local st = require "util.stanza"; |
19 local componentmanager = require "core.componentmanager"; | 19 local componentmanager = require "core.componentmanager"; |
20 local config_get = require "core.configmanager".get; | 20 local config_get = require "core.configmanager".get; |
21 local connlisteners = require "net.connlisteners"; | 21 local connlisteners = require "net.connlisteners"; |
22 local sha1 = require "util.hashes".sha1; | 22 local sha1 = require "util.hashes".sha1; |
135 reply.attr.id = stanza.attr.id; | 135 reply.attr.id = stanza.attr.id; |
136 reply.attr.to = stanza.attr.from; | 136 reply.attr.to = stanza.attr.from; |
137 return reply; | 137 return reply; |
138 end | 138 end |
139 | 139 |
140 local function _jid_join(node, host, resource) | |
141 local ret = host; | |
142 if ret then | |
143 if node then | |
144 ret = node .. "@" .. ret; | |
145 end | |
146 if resource then | |
147 ret = ret .. "/" .. resource; | |
148 end | |
149 end | |
150 return ret; | |
151 end | |
152 | |
153 local function get_stream_host(origin, stanza) | 140 local function get_stream_host(origin, stanza) |
154 local reply = replies_cache.stream_host; | 141 local reply = replies_cache.stream_host; |
155 local err_reply = replies_cache.stream_host_err; | 142 local err_reply = replies_cache.stream_host_err; |
156 local sid = stanza.tags[1].attr.sid; | 143 local sid = stanza.tags[1].attr.sid; |
157 local allow = false; | 144 local allow = false; |
183 :query("http://jabber.org/protocol/bytestreams") | 170 :query("http://jabber.org/protocol/bytestreams") |
184 :tag("streamhost", {jid=host, host=proxy_address, port=proxy_port}); | 171 :tag("streamhost", {jid=host, host=proxy_address, port=proxy_port}); |
185 replies_cache.stream_host = reply; | 172 replies_cache.stream_host = reply; |
186 end | 173 end |
187 else | 174 else |
188 module:log("warn", "Denying use of proxy for %s", tostring(_jid_join(jid_node, jid_host, jid_resource))); | 175 module:log("warn", "Denying use of proxy for %s", tostring(jid_join(jid_node, jid_host, jid_resource))); |
189 if err_reply == nil then | 176 if err_reply == nil then |
190 err_reply = st.iq({type="error", from=host}) | 177 err_reply = st.iq({type="error", from=host}) |
191 :query("http://jabber.org/protocol/bytestreams") | 178 :query("http://jabber.org/protocol/bytestreams") |
192 :tag("error", {code='403', type='auth'}) | 179 :tag("error", {code='403', type='auth'}) |
193 :tag("forbidden", {xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'}); | 180 :tag("forbidden", {xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'}); |