Comparison

mod_audit_auth/mod_audit_auth.lua @ 5803:f199bff16f1f

mod_audit_auth: Improve user-agent building (fixes traceback)
author Matthew Wild <mwild1@gmail.com>
date Thu, 07 Dec 2023 13:02:36 +0000
parent 5772:238c4ac8b735
child 5930:cc30c4b5f006
comparison
equal deleted inserted replaced
5802:6ab9e1763f35 5803:f199bff16f1f
25 25
26 module:hook("client_management/new-client", function (event) 26 module:hook("client_management/new-client", function (event)
27 local session, client = event.session, event.client; 27 local session, client = event.session, event.client;
28 28
29 local client_info = st.stanza("client", { id = client.id }); 29 local client_info = st.stanza("client", { id = client.id });
30
30 if client.user_agent then 31 if client.user_agent then
31 client_info:text_tag("agent", client.user_agent); 32 local user_agent = st.stanza("user-agent", { xmlns = "urn:xmpp:sasl:2" })
33 if client.user_agent.software then
34 user_agent:text_tag("software", client.user_agent.software, { id = client.user_agent.software_id; version = client.user_agent.software_version });
35 end
36 if client.user_agent.device then
37 user_agent:text_tag("device", client.user_agent.device);
38 end
39 if client.user_agent.uri then
40 user_agent:text_tag("uri", client.user_agent.uri);
41 end
42 client_info:add_child(user_agent);
32 end 43 end
44
33 if client.legacy then 45 if client.legacy then
34 client_info:text_tag("legacy"); 46 client_info:text_tag("legacy");
35 end 47 end
36 48
37 module:audit(jid.join(session.username, module.host), "new-client", { 49 module:audit(jid.join(session.username, module.host), "new-client", {