Mercurial > prosody-modules
comparison mod_audit/mod_audit.lua @ 5708: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 | 9a5fca9f90a6 |
| children | 0c9606770db1 |
comparison
equal
deleted
inserted
replaced
| 5707:9a5fca9f90a6 | 5708:37ba9478b387 |
|---|---|
| 90 network = get_ip_network(remote_ip); | 90 network = get_ip_network(remote_ip); |
| 91 end | 91 end |
| 92 stanza:text_tag("remote-ip", network or remote_ip.normal); | 92 stanza:text_tag("remote-ip", network or remote_ip.normal); |
| 93 end | 93 end |
| 94 if attach_location and remote_ip then | 94 if attach_location and remote_ip then |
| 95 local geoip_country = ip.proto == "IPv6" and geoip6_country or geoip4_country; | 95 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); |
| 96 stanza:tag("location", { | 96 stanza:tag("location", { |
| 97 country = geoip_country:query_by_addr(remote_ip.normal); | 97 country = geoip_info.code; |
| 98 }):up(); | 98 }):up(); |
| 99 end | 99 end |
| 100 if session.client_id then | 100 if session.client_id then |
| 101 stanza:text_tag("client", session.client_id); | 101 stanza:text_tag("client", session.client_id); |
| 102 end | 102 end |
