bryancall commented on issue #11812:
URL:
https://github.com/apache/trafficserver/issues/11812#issuecomment-4014770230
There were two bugs here, both now fixed:
**1. Remap plugin loading (fixed in #12126):** The `std::call_once` for
`initHRWLibraries` was outside the `if` block that checks for `--geo-db-path`,
so when header_rewrite was used as a remap plugin, the library init was called
with an empty path and then skipped on subsequent calls. This was fixed by
@cmcfarlen in #12126 (merged March 2025).
**2. Incorrect MMDB field paths (fix incoming):** The MaxMind lookup code
used flat field names that don't match the structure of standard GeoLite2/DBIP
mmdb databases:
- `GEO_QUAL_COUNTRY` queried `"country_code"` — but the correct path is
`"country" -> "names" -> "en"`
- `GEO_QUAL_COUNTRY_ISO` was completely missing from `get_geo_string()` —
the correct path is `"country" -> "iso_code"`
- There was also a bug where `gMaxMindDB` wasn't set to `nullptr` after
`delete` on open failure, preventing retry
Verified the fix with DBIP Country Lite and ASN Lite databases:
```
$ ./test_mmdb dbip-country-lite.mmdb 1.201.194.27
COUNTRY: South Korea
COUNTRY-ISO: KR
$ ./test_mmdb dbip-asn-lite.mmdb 1.201.194.27
ASN-NAME: KINX
ASN: 9286
```
The field paths now match what the `maxmind_acl` plugin uses (which works
correctly).
Note: `%{GEO:COUNTRY-ISO}` is currently typed as an integer in the
header_rewrite dispatcher (inherited from the old GeoIP backend where it
returned a numeric country ID). With MaxMind, the ISO code is a string ("KR"),
so using `set-header` with `%{GEO:COUNTRY-ISO}` will return the numeric
geoname_id rather than the ISO string. Use `%{GEO:COUNTRY}` for the country
name. This int/string typing issue is a pre-existing design limitation that
could be addressed separately.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]