Software /
code /
prosody
Comparison
core/stanza_router.lua @ 10528:48300484a124
core.stanza_router: Extract host part of JIDs directly [luacheck]
Silences warning about unused return values
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 20 Dec 2019 22:31:27 +0100 |
parent | 10362:c05444119e9e |
child | 10529:854586ac7c96 |
comparison
equal
deleted
inserted
replaced
10527:d59be9befad7 | 10528:48300484a124 |
---|---|
10 | 10 |
11 local hosts = _G.prosody.hosts; | 11 local hosts = _G.prosody.hosts; |
12 local tostring = tostring; | 12 local tostring = tostring; |
13 local st = require "util.stanza"; | 13 local st = require "util.stanza"; |
14 local jid_split = require "util.jid".split; | 14 local jid_split = require "util.jid".split; |
15 local jid_host = require "util.jid".host; | |
15 local jid_prepped_split = require "util.jid".prepped_split; | 16 local jid_prepped_split = require "util.jid".prepped_split; |
16 | 17 |
17 local full_sessions = _G.prosody.full_sessions; | 18 local full_sessions = _G.prosody.full_sessions; |
18 local bare_sessions = _G.prosody.bare_sessions; | 19 local bare_sessions = _G.prosody.bare_sessions; |
19 | 20 |
79 local node, host, resource; | 80 local node, host, resource; |
80 local from_node, from_host, from_resource; | 81 local from_node, from_host, from_resource; |
81 local to_bare, from_bare; | 82 local to_bare, from_bare; |
82 if to then | 83 if to then |
83 if full_sessions[to] or bare_sessions[to] or hosts[to] then | 84 if full_sessions[to] or bare_sessions[to] or hosts[to] then |
84 node, host = jid_split(to); -- TODO only the host is needed, optimize | 85 host = jid_host(to); |
85 else | 86 else |
86 node, host, resource = jid_prepped_split(to); | 87 node, host, resource = jid_prepped_split(to); |
87 if not host then | 88 if not host then |
88 log("warn", "Received stanza with invalid destination JID: %s", to); | 89 log("warn", "Received stanza with invalid destination JID: %s", to); |
89 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then | 90 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then |
184 core_route_stanza(origin, stanza); | 185 core_route_stanza(origin, stanza); |
185 end | 186 end |
186 end | 187 end |
187 | 188 |
188 function core_route_stanza(origin, stanza) | 189 function core_route_stanza(origin, stanza) |
189 local node, host, resource = jid_split(stanza.attr.to); | 190 local host = jid_host(stanza.attr.to); |
190 local from_node, from_host, from_resource = jid_split(stanza.attr.from); | 191 local from_host = jid_host(stanza.attr.from); |
191 | 192 |
192 -- Auto-detect origin if not specified | 193 -- Auto-detect origin if not specified |
193 origin = origin or hosts[from_host]; | 194 origin = origin or hosts[from_host]; |
194 if not origin then return false; end | 195 if not origin then return false; end |
195 | 196 |