Software /
code /
prosody
Comparison
plugins/mod_s2s/mod_s2s.lua @ 5975:0d219631d47b
mod_s2s: Include IP in log messages, if host is unavailable
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Sun, 05 Jan 2014 22:21:50 +0100 |
parent | 5769:f6ea5b3739c9 |
child | 5978:d21ea6001bba |
child | 6359:c74670b3be53 |
comparison
equal
deleted
inserted
replaced
5974:9ce0d246c851 | 5975:0d219631d47b |
---|---|
354 local features = st.stanza("stream:features"); | 354 local features = st.stanza("stream:features"); |
355 | 355 |
356 if to then | 356 if to then |
357 hosts[to].events.fire_event("s2s-stream-features", { origin = session, features = features }); | 357 hosts[to].events.fire_event("s2s-stream-features", { origin = session, features = features }); |
358 else | 358 else |
359 (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", from or "unknown host"); | 359 (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", from or session.ip or "unknown host"); |
360 end | 360 end |
361 | 361 |
362 log("debug", "Sending stream features: %s", tostring(features)); | 362 log("debug", "Sending stream features: %s", tostring(features)); |
363 send(features); | 363 send(features); |
364 end | 364 end |
455 session:open_stream(session.from_host, session.to_host); | 455 session:open_stream(session.from_host, session.to_host); |
456 end | 456 end |
457 end | 457 end |
458 if reason then -- nil == no err, initiated by us, false == initiated by remote | 458 if reason then -- nil == no err, initiated by us, false == initiated by remote |
459 if type(reason) == "string" then -- assume stream error | 459 if type(reason) == "string" then -- assume stream error |
460 log("debug", "Disconnecting %s[%s], <stream:error> is: %s", session.host or "(unknown host)", session.type, reason); | 460 log("debug", "Disconnecting %s[%s], <stream:error> is: %s", session.host or session.ip or "(unknown host)", session.type, reason); |
461 session.sends2s(st.stanza("stream:error"):tag(reason, {xmlns = 'urn:ietf:params:xml:ns:xmpp-streams' })); | 461 session.sends2s(st.stanza("stream:error"):tag(reason, {xmlns = 'urn:ietf:params:xml:ns:xmpp-streams' })); |
462 elseif type(reason) == "table" then | 462 elseif type(reason) == "table" then |
463 if reason.condition then | 463 if reason.condition then |
464 local stanza = st.stanza("stream:error"):tag(reason.condition, stream_xmlns_attr):up(); | 464 local stanza = st.stanza("stream:error"):tag(reason.condition, stream_xmlns_attr):up(); |
465 if reason.text then | 465 if reason.text then |
466 stanza:tag("text", stream_xmlns_attr):text(reason.text):up(); | 466 stanza:tag("text", stream_xmlns_attr):text(reason.text):up(); |
467 end | 467 end |
468 if reason.extra then | 468 if reason.extra then |
469 stanza:add_child(reason.extra); | 469 stanza:add_child(reason.extra); |
470 end | 470 end |
471 log("debug", "Disconnecting %s[%s], <stream:error> is: %s", session.host or "(unknown host)", session.type, tostring(stanza)); | 471 log("debug", "Disconnecting %s[%s], <stream:error> is: %s", session.host or session.ip or "(unknown host)", session.type, tostring(stanza)); |
472 session.sends2s(stanza); | 472 session.sends2s(stanza); |
473 elseif reason.name then -- a stanza | 473 elseif reason.name then -- a stanza |
474 log("debug", "Disconnecting %s->%s[%s], <stream:error> is: %s", session.from_host or "(unknown host)", session.to_host or "(unknown host)", session.type, tostring(reason)); | 474 log("debug", "Disconnecting %s->%s[%s], <stream:error> is: %s", session.from_host or "(unknown host)", session.to_host or "(unknown host)", session.type, tostring(reason)); |
475 session.sends2s(reason); | 475 session.sends2s(reason); |
476 end | 476 end |
641 elseif must_secure and insecure_domains[host] then | 641 elseif must_secure and insecure_domains[host] then |
642 must_secure = false; | 642 must_secure = false; |
643 end | 643 end |
644 | 644 |
645 if must_secure and (session.cert_chain_status ~= "valid" or session.cert_identity_status ~= "valid") then | 645 if must_secure and (session.cert_chain_status ~= "valid" or session.cert_identity_status ~= "valid") then |
646 module:log("warn", "Forbidding insecure connection to/from %s", host); | 646 module:log("warn", "Forbidding insecure connection to/from %s", host or session.ip or "(unknown host)"); |
647 if session.direction == "incoming" then | 647 if session.direction == "incoming" then |
648 session:close({ condition = "not-authorized", text = "Your server's certificate is invalid, expired, or not trusted by "..session.to_host }); | 648 session:close({ condition = "not-authorized", text = "Your server's certificate is invalid, expired, or not trusted by "..session.to_host }); |
649 else -- Close outgoing connections without warning | 649 else -- Close outgoing connections without warning |
650 session:close(false); | 650 session:close(false); |
651 end | 651 end |