[PR #2297] [MERGED] [management] Auto update geolite #14954

Closed
opened 2026-08-05 03:06:40 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/2297
Author: @benniekiss
Created: 7/21/2024
Status: Merged
Merged: 9/9/2024
Merged by: @mlsmaycon

Base: mainHead: auto_update_geolite


📝 Commits (10+)

  • 37f82bb automatically update GeoLite databases
  • c48db30 handle if getFilenameFromURL() fails
  • 261f138 update db names in 'test geolocation databases'
  • bad3cf6 use string formatting for log message
  • a3bafc5 refactor to allow disabling auto-updating geolite
  • 627d268 add unit test for geolocation.GetMaxMindFilenames()
  • d6ebc20 fix name scheme in failing test
  • a46d2db fix log line
  • f63ef77 correctly handle commandline option
  • 701964e remove unused functions

📊 Changes

14 files changed (+193 additions, -328 deletions)

View changed files

📝 .github/workflows/test-infrastructure-files.yml (+4 -22)
📝 .gitignore (+0 -1)
client/ui/bundled.go (+12 -0)
infrastructure_files/download-geolite2.sh (+0 -109)
📝 management/cmd/management.go (+5 -3)
📝 management/cmd/root.go (+2 -0)
📝 management/server/geolocation/database.go (+25 -27)
📝 management/server/geolocation/geolocation.go (+107 -88)
📝 management/server/geolocation/geolocation_test.go (+4 -10)
📝 management/server/geolocation/store.go (+9 -63)
📝 management/server/geolocation/utils.go (+19 -0)
📝 management/server/http/geolocation_handler_test.go (+6 -5)
📝 management/server/testdata/GeoLite2-City_20240305.mmdb (+0 -0)
📝 management/server/testdata/geonames_20240305.db (+0 -0)

📄 Description

Describe your changes

Introduces automated updates for GeoLite databases, eliminating the need to manually run the download-geolite2.sh script. Key changes include functions to fetch and update database files based on versioned filenames, auto-download logic when outdated files are detected, and a new --disable-geolite-update flag.

By default, this flag is set to true, disabling automatic updates. Users who want to enable auto-updates can do so by setting --disable-geolite-update=false. Additionally, obsolete scripts and reload functions have been removed.

This update simplifies version tracking and ensures database consistency without manual intervention while offering flexibility for self-hosted users.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/2297 **Author:** [@benniekiss](https://github.com/benniekiss) **Created:** 7/21/2024 **Status:** ✅ Merged **Merged:** 9/9/2024 **Merged by:** [@mlsmaycon](https://github.com/mlsmaycon) **Base:** `main` ← **Head:** `auto_update_geolite` --- ### 📝 Commits (10+) - [`37f82bb`](https://github.com/netbirdio/netbird/commit/37f82bb287b368030549082d31324f07d9426e36) automatically update GeoLite databases - [`c48db30`](https://github.com/netbirdio/netbird/commit/c48db30a0da45bd06def54b0358fcea3c3aa8bfb) handle if getFilenameFromURL() fails - [`261f138`](https://github.com/netbirdio/netbird/commit/261f13878bb8b24f23df87295ecbf46533b307ea) update db names in 'test geolocation databases' - [`bad3cf6`](https://github.com/netbirdio/netbird/commit/bad3cf641664be2f48257705ee5bed1b232656db) use string formatting for log message - [`a3bafc5`](https://github.com/netbirdio/netbird/commit/a3bafc5854704ed4258321e8bb2904408859910c) refactor to allow disabling auto-updating geolite - [`627d268`](https://github.com/netbirdio/netbird/commit/627d268e5acfa3248a7643d2b28665bc94583370) add unit test for geolocation.GetMaxMindFilenames() - [`d6ebc20`](https://github.com/netbirdio/netbird/commit/d6ebc20be33c2788667e960ca6ce0e35dc2de207) fix name scheme in failing test - [`a46d2db`](https://github.com/netbirdio/netbird/commit/a46d2db25eb52d85d09b1114627f8134c0901663) fix log line - [`f63ef77`](https://github.com/netbirdio/netbird/commit/f63ef779eb33b2ccdfaeaef25975a7c7bf9a264c) correctly handle commandline option - [`701964e`](https://github.com/netbirdio/netbird/commit/701964eab8f0bea5165cf2842465ff3695b4d629) remove unused functions ### 📊 Changes **14 files changed** (+193 additions, -328 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/test-infrastructure-files.yml` (+4 -22) 📝 `.gitignore` (+0 -1) ➕ `client/ui/bundled.go` (+12 -0) ➖ `infrastructure_files/download-geolite2.sh` (+0 -109) 📝 `management/cmd/management.go` (+5 -3) 📝 `management/cmd/root.go` (+2 -0) 📝 `management/server/geolocation/database.go` (+25 -27) 📝 `management/server/geolocation/geolocation.go` (+107 -88) 📝 `management/server/geolocation/geolocation_test.go` (+4 -10) 📝 `management/server/geolocation/store.go` (+9 -63) 📝 `management/server/geolocation/utils.go` (+19 -0) 📝 `management/server/http/geolocation_handler_test.go` (+6 -5) 📝 `management/server/testdata/GeoLite2-City_20240305.mmdb` (+0 -0) 📝 `management/server/testdata/geonames_20240305.db` (+0 -0) </details> ### 📄 Description ## Describe your changes Introduces automated updates for GeoLite databases, eliminating the need to manually run the `download-geolite2.sh` script. Key changes include functions to fetch and update database files based on versioned filenames, auto-download logic when outdated files are detected, and a new `--disable-geolite-update` flag. By default, this flag is set to true, disabling automatic updates. Users who want to enable auto-updates can do so by setting `--disable-geolite-update=false`. Additionally, obsolete scripts and reload functions have been removed. This update simplifies version tracking and ensures database consistency without manual intervention while offering flexibility for self-hosted users. ## Issue ticket number and link ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [x] It is a refactor - [ ] Created tests that fail without the change (if possible) - [x] Extended the README / documentation, if necessary --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 03:06:40 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#14954