comparison mod_cache_c2s_caps/mod_cache_c2s_caps.lua @ 4320:8fc16174fec6

mod_cache_c2s_caps: log full JID on all relevant code paths
author Georg Lukas <georg@op-co.de>
date Fri, 22 May 2020 09:47:42 +0200
parents f27becd421bd
children
comparison
equal deleted inserted replaced
4319:caaa40f072da 4320:8fc16174fec6
66 return; 66 return;
67 end 67 end
68 68
69 local caps = stanza:get_child("c", "http://jabber.org/protocol/caps"); 69 local caps = stanza:get_child("c", "http://jabber.org/protocol/caps");
70 if caps == nil then 70 if caps == nil then
71 origin.log("debug", "Presence without caps received, skipping"); 71 origin.log("debug", "Presence from %s without caps received, skipping", from);
72 return; 72 return;
73 end 73 end
74 74
75 local hash = caps.attr.hash; 75 local hash = caps.attr.hash;
76 local node = caps.attr.node; 76 local node = caps.attr.node;
77 local ver = caps.attr.ver; 77 local ver = caps.attr.ver;
78 if not hash or not node or not ver then 78 if not hash or not node or not ver then
79 return; 79 return;
80 end 80 end
81 if hash ~= "sha-1" then 81 if hash ~= "sha-1" then
82 origin.log("warn", "Non-SHA-1 caps received: %s", hash); 82 origin.log("warn", "Presence from %s with non-SHA-1 caps : %s", from, hash);
83 return; 83 return;
84 end 84 end
85 85
86 local node_query = node.."#"..ver; 86 local node_query = node.."#"..ver;
87 if (origin.caps_cache and origin.caps_cache.attr.node == node_query) or in_flight_iqs[from..node_query] ~= nil then 87 if (origin.caps_cache and origin.caps_cache.attr.node == node_query) or in_flight_iqs[from..node_query] ~= nil then
88 origin.log("debug", "Already requested these caps, skipping"); 88 origin.log("debug", "Already requested these caps, skipping");
89 return; 89 return;
90 end 90 end
91 91
92 origin.log("debug", "Received presence from %s with SHA-1 caps %s, querying disco#info", from, node_query); 92 origin.log("debug", "Presence from %s with SHA-1 caps %s, querying disco#info", from, node_query);
93 93
94 local id = uuid_gen(); 94 local id = uuid_gen();
95 iq_node_map[from..id] = node_query 95 iq_node_map[from..id] = node_query
96 local iq = st_iq({ type = "get", from = module.host, to = from, id = id }) 96 local iq = st_iq({ type = "get", from = module.host, to = from, id = id })
97 :tag("query", { xmlns = "http://jabber.org/protocol/disco#info", node = node_query }); 97 :tag("query", { xmlns = "http://jabber.org/protocol/disco#info", node = node_query });