# HG changeset patch # User Kim Alvefur # Date 1699873517 -3600 # Node ID 9a5fca9f90a60bb162cdfabfde5fbd705e6300c0 # Parent 655f90b149a4f407e5400fd0d8a7945775f777e5 mod_audit: Parse IP into util.ip object once and reuse Mostly for my own sanity diff -r 655f90b149a4 -r 9a5fca9f90a6 mod_audit/mod_audit.lua --- a/mod_audit/mod_audit.lua Mon Nov 13 12:02:54 2023 +0100 +++ b/mod_audit/mod_audit.lua Mon Nov 13 12:05:17 2023 +0100 @@ -83,15 +83,15 @@ attr.type = session.type; end local stanza = st.stanza("session", attr); - if attach_ips and session.ip then - local remote_ip, network = session.ip; + local remote_ip = session.ip and ip.new_ip(session.ip); + if attach_ips and remote_ip then + local network; if attach_ipv4_prefix or attach_ipv6_prefix then network = get_ip_network(remote_ip); end stanza:text_tag("remote-ip", network or remote_ip.normal); end - if attach_location and session.ip then - local remote_ip = ip.new_ip(session.ip); + if attach_location and remote_ip then local geoip_country = ip.proto == "IPv6" and geoip6_country or geoip4_country; stanza:tag("location", { country = geoip_country:query_by_addr(remote_ip.normal);