Changeset

5731:37ba9478b387

mod_audit: Fix recording location info The method :query_by_addr only works for IPv4, even if you open the IPv6 database, which is an odd API. It also returns a table, not a string.
author Kim Alvefur <zash@zash.se>
date Mon, 13 Nov 2023 12:14:31 +0100
parents 5730:9a5fca9f90a6
children 5732:0c9606770db1
files mod_audit/mod_audit.lua
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_audit/mod_audit.lua	Mon Nov 13 12:05:17 2023 +0100
+++ b/mod_audit/mod_audit.lua	Mon Nov 13 12:14:31 2023 +0100
@@ -92,9 +92,9 @@
 		stanza:text_tag("remote-ip", network or remote_ip.normal);
 	end
 	if attach_location and remote_ip then
-		local geoip_country = ip.proto == "IPv6" and geoip6_country or geoip4_country;
+		local geoip_info = remote_ip.proto == "IPv6" and geoip6_country:query_by_addr6(remote_ip.normal) or geoip4_country:query_by_addr(remote_ip.normal);
 		stanza:tag("location", {
-			country = geoip_country:query_by_addr(remote_ip.normal);
+			country = geoip_info.code;
 		}):up();
 	end
 	if session.client_id then