Summary
Add a shared IP geolocation service backed by the free ip66.dev MMDB database (CC BY 4.0, no API key required).
Changes
New package: shared/go/api/ipdb/
| File |
Purpose |
types.go |
IPRecord, SyncStatus, internal mmdbRecord |
store.go |
PostgreSQL table creation, cache CRUD, sync log |
lookup.go |
Hot-swappable MMDB reader, LookupIP with cache |
sync.go |
Daily download scheduler, atomic file replacement, Init/Shutdown |
New handler file: shared/go/api/RequestHandlers/ipdb_handlers.go
HandleIPLookup — GET /shared_api/v1/ipdb/lookup?ip=<addr>
HandleIPSyncStatus — GET /shared_api/v1/ipdb/sync/status
HandleIPSyncTrigger — POST /shared_api/v1/ipdb/sync/trigger (admin)
Modified files
api/sysdatastores/createtables.go — calls ipdb.CreateTables(logger)
api/router.go — registers the three new endpoints
go.mod / go.sum — adds github.com/oschwald/maxminddb-golang v1.13.1
New documentation
shared/Documents/services/ipdb/README.md
Database tables
ipdb_lookup_cache — caches recent lookups (configurable TTL, default 7 days)
ipdb_sync_log — audit trail of every sync attempt
Configuration
| Env var |
Default |
Description |
IPDB_FILE_PATH |
/var/data/ip66.mmdb |
Local MMDB file path |
IPDB_CACHE_TTL_DAYS |
7 |
Lookup cache TTL |
Integration steps for consuming projects
Call ipdb.Init(logger) once at startup (after sysdatastores.CreateSysTables), and ipdb.Shutdown() on graceful stop.
sysdatastores.CreateSysTables(logger)
ipdb.Init(logger)
defer ipdb.Shutdown()
Data provided per IP
- ASN number + organisation name
- Country name + ISO 3166-1 alpha-2 code
- Continent name + two-letter code
- IPv4 and IPv6 supported
Summary
Add a shared IP geolocation service backed by the free ip66.dev MMDB database (CC BY 4.0, no API key required).
Changes
New package:
shared/go/api/ipdb/types.goIPRecord,SyncStatus, internalmmdbRecordstore.golookup.goLookupIPwith cachesync.goInit/ShutdownNew handler file:
shared/go/api/RequestHandlers/ipdb_handlers.goHandleIPLookup—GET /shared_api/v1/ipdb/lookup?ip=<addr>HandleIPSyncStatus—GET /shared_api/v1/ipdb/sync/statusHandleIPSyncTrigger—POST /shared_api/v1/ipdb/sync/trigger(admin)Modified files
api/sysdatastores/createtables.go— callsipdb.CreateTables(logger)api/router.go— registers the three new endpointsgo.mod/go.sum— addsgithub.com/oschwald/maxminddb-golang v1.13.1New documentation
shared/Documents/services/ipdb/README.mdDatabase tables
ipdb_lookup_cache— caches recent lookups (configurable TTL, default 7 days)ipdb_sync_log— audit trail of every sync attemptConfiguration
IPDB_FILE_PATH/var/data/ip66.mmdbIPDB_CACHE_TTL_DAYS7Integration steps for consuming projects
Call
ipdb.Init(logger)once at startup (aftersysdatastores.CreateSysTables), andipdb.Shutdown()on graceful stop.Data provided per IP