Comparison

plugins/mod_s2s/mod_s2s.lua @ 9412:063977461363

mod_s2s: Silence all warnings instead of ignoring the entire module
author Kim Alvefur <zash@zash.se>
date Sun, 30 Sep 2018 17:49:56 +0200
parent 9070:21730a3642fe
child 9449:94033a2529b9
comparison
equal deleted inserted replaced
9411:62c876e333e4 9412:063977461363
117 stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza); 117 stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza);
118 }; 118 };
119 if host.sendq then 119 if host.sendq then
120 t_insert(host.sendq, queued_item); 120 t_insert(host.sendq, queued_item);
121 else 121 else
122 -- luacheck: ignore 122
122 host.sendq = { queued_item }; 123 host.sendq = { queued_item };
123 end 124 end
124 host.log("debug", "stanza [%s] queued ", stanza.name); 125 host.log("debug", "stanza [%s] queued ", stanza.name);
125 return true; 126 return true;
126 elseif host.type == "local" or host.type == "component" then 127 elseif host.type == "local" or host.type == "component" then
173 end 174 end
174 module:hook("route/remote", route_to_existing_session, -1); 175 module:hook("route/remote", route_to_existing_session, -1);
175 module:hook("route/remote", route_to_new_session, -10); 176 module:hook("route/remote", route_to_new_session, -10);
176 module:hook("s2s-authenticated", make_authenticated, -1); 177 module:hook("s2s-authenticated", make_authenticated, -1);
177 module:hook("s2s-read-timeout", keepalive, -1); 178 module:hook("s2s-read-timeout", keepalive, -1);
178 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) 179 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) -- luacheck: ignore 212/stanza
179 if session.type == "s2sout" then 180 if session.type == "s2sout" then
180 -- Stream is authenticated and we are seem to be done with feature negotiation, 181 -- Stream is authenticated and we are seem to be done with feature negotiation,
181 -- so the stream is ready for stanzas. RFC 6120 Section 4.3 182 -- so the stream is ready for stanzas. RFC 6120 Section 4.3
182 mark_connected(session); 183 mark_connected(session);
183 return true; 184 return true;
495 stanza:tag("text", stream_xmlns_attr):text(reason.text):up(); 496 stanza:tag("text", stream_xmlns_attr):text(reason.text):up();
496 end 497 end
497 if reason.extra then 498 if reason.extra then
498 stanza:add_child(reason.extra); 499 stanza:add_child(reason.extra);
499 end 500 end
500 log("debug", "Disconnecting %s[%s], <stream:error> is: %s", session.host or session.ip or "(unknown host)", session.type, stanza); 501 log("debug", "Disconnecting %s[%s], <stream:error> is: %s",
502 session.host or session.ip or "(unknown host)", session.type, stanza);
501 session.sends2s(stanza); 503 session.sends2s(stanza);
502 elseif reason.name then -- a stanza 504 elseif reason.name then -- a stanza
503 log("debug", "Disconnecting %s->%s[%s], <stream:error> is: %s", session.from_host or "(unknown host)", session.to_host or "(unknown host)", session.type, reason); 505 log("debug", "Disconnecting %s->%s[%s], <stream:error> is: %s",
506 session.from_host or "(unknown host)", session.to_host or "(unknown host)",
507 session.type, reason);
504 session.sends2s(reason); 508 session.sends2s(reason);
505 end 509 end
506 end 510 end
507 end 511 end
508 512
509 session.sends2s("</stream:stream>"); 513 session.sends2s("</stream:stream>");
510 function session.sends2s() return false; end 514 function session.sends2s() return false; end
511 515
516 -- luacheck: ignore 422/reason
517 -- FIXME reason should be managed in a place common to c2s, s2s, bosh, component etc
512 local reason = remote_reason or (reason and (reason.text or reason.condition)) or reason; 518 local reason = remote_reason or (reason and (reason.text or reason.condition)) or reason;
513 session.log("info", "%s s2s stream %s->%s closed: %s", session.direction:gsub("^.", string.upper), session.from_host or "(unknown host)", session.to_host or "(unknown host)", reason or "stream closed"); 519 session.log("info", "%s s2s stream %s->%s closed: %s", session.direction:gsub("^.", string.upper),
520 session.from_host or "(unknown host)", session.to_host or "(unknown host)", reason or "stream closed");
514 521
515 -- Authenticated incoming stream may still be sending us stanzas, so wait for </stream:stream> from remote 522 -- Authenticated incoming stream may still be sending us stanzas, so wait for </stream:stream> from remote
516 local conn = session.conn; 523 local conn = session.conn;
517 if reason == nil and not session.notopen and session.type == "s2sin" then 524 if reason == nil and not session.notopen and session.type == "s2sin" then
518 add_task(stream_close_timeout, function () 525 add_task(stream_close_timeout, function ()
527 conn:close(); -- Close immediately, as this is an outgoing connection or is not authed 534 conn:close(); -- Close immediately, as this is an outgoing connection or is not authed
528 end 535 end
529 end 536 end
530 end 537 end
531 538
532 function session_stream_attrs(session, from, to, attr) 539 function session_stream_attrs(session, from, to, attr) -- luacheck: ignore 212/session
533 if not from or (hosts[from] and hosts[from].modules.dialback) then 540 if not from or (hosts[from] and hosts[from].modules.dialback) then
534 attr["xmlns:db"] = 'jabber:server:dialback'; 541 attr["xmlns:db"] = 'jabber:server:dialback';
535 end 542 end
536 if not from then 543 if not from then
537 attr.from = ''; 544 attr.from = '';
595 end 602 end
596 603
597 session.close = session_close; 604 session.close = session_close;
598 605
599 local handlestanza = stream_callbacks.handlestanza; 606 local handlestanza = stream_callbacks.handlestanza;
600 function session.dispatch_stanza(session, stanza) 607 function session.dispatch_stanza(session, stanza) -- luacheck: ignore 432/session
601 return handlestanza(session, stanza); 608 return handlestanza(session, stanza);
602 end 609 end
603 610
604 module:fire_event("s2s-created", { session = session }); 611 module:fire_event("s2s-created", { session = session });
605 612