[PR #1517] [MERGED] Extend peer meta with location information #15499

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/1517
Author: @surik
Created: 2/1/2024
Status: Merged
Merged: 2/6/2024
Merged by: @surik

Base: feature/posture-checksHead: yury/resolve-ip-to-location


📝 Commits (8)

  • bb08dee Extract location by real ip as peer meta on sync
  • c29c150 Save peer location
  • 22493bf Test SavePeerLocation
  • 66044e9 Use net.IP type
  • 5747932 Remove TODO
  • d3c5d11 Fix linter
  • 740b64f Return geoname_id, public_ip and kernel_version as peer info
  • 80b812d Move Location out of Meta to Peer level

📊 Changes

19 files changed (+260 additions, -76 deletions)

View changed files

📝 management/cmd/management.go (+1 -1)
📝 management/server/account.go (+1 -1)
📝 management/server/account_test.go (+3 -3)
📝 management/server/file_store.go (+21 -0)
📝 management/server/file_store_test.go (+49 -0)
📝 management/server/geolocation/geolocation.go (+2 -7)
📝 management/server/geolocation/geolocation_test.go (+2 -4)
📝 management/server/grpcserver.go (+9 -8)
📝 management/server/http/api/openapi.yml (+12 -0)
📝 management/server/http/api/types.gen.go (+27 -0)
📝 management/server/http/peers_handler.go (+17 -0)
📝 management/server/mock_server/account_mock.go (+4 -3)
📝 management/server/peer.go (+19 -1)
📝 management/server/peer/peer.go (+11 -6)
📝 management/server/posture/geo_location.go (+2 -2)
📝 management/server/posture/geo_location_test.go (+24 -40)
📝 management/server/sqlite_store.go (+12 -0)
📝 management/server/sqlite_store_test.go (+43 -0)
📝 management/server/store.go (+1 -0)

📄 Description

Describe your changes

This PR uses the geolocation service to resolve IP to location. The lookup happens once on the first connection - when a client calls the Sync procedure.
The location is stored as part of the peer:

type Location struct {
	ConnectionIP net.IP 
	CountryCode  string
	CityName     string
	GeoNameID    uint 
}

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/1517 **Author:** [@surik](https://github.com/surik) **Created:** 2/1/2024 **Status:** ✅ Merged **Merged:** 2/6/2024 **Merged by:** [@surik](https://github.com/surik) **Base:** `feature/posture-checks` ← **Head:** `yury/resolve-ip-to-location` --- ### 📝 Commits (8) - [`bb08dee`](https://github.com/netbirdio/netbird/commit/bb08dee781fefe1b0e97b5f1d8a3debca77f696c) Extract location by real ip as peer meta on sync - [`c29c150`](https://github.com/netbirdio/netbird/commit/c29c150e061df8fb8b53eb76d06f339c89c2d9d0) Save peer location - [`22493bf`](https://github.com/netbirdio/netbird/commit/22493bfaedd97690f06a12f521eb3ee0cc1c1d52) Test SavePeerLocation - [`66044e9`](https://github.com/netbirdio/netbird/commit/66044e931fe224b02f1aac1f5d2b95684cedc160) Use net.IP type - [`5747932`](https://github.com/netbirdio/netbird/commit/5747932fc962412a801d1ef1b8aa208cafd8c00c) Remove TODO - [`d3c5d11`](https://github.com/netbirdio/netbird/commit/d3c5d112154a8a58613dd84d9575042998dc957b) Fix linter - [`740b64f`](https://github.com/netbirdio/netbird/commit/740b64fe58ca614acc8b15be8823e828877e06f5) Return geoname_id, public_ip and kernel_version as peer info - [`80b812d`](https://github.com/netbirdio/netbird/commit/80b812d330c47ce5e16ce071d49ed6f09fe79a57) Move Location out of Meta to Peer level ### 📊 Changes **19 files changed** (+260 additions, -76 deletions) <details> <summary>View changed files</summary> 📝 `management/cmd/management.go` (+1 -1) 📝 `management/server/account.go` (+1 -1) 📝 `management/server/account_test.go` (+3 -3) 📝 `management/server/file_store.go` (+21 -0) 📝 `management/server/file_store_test.go` (+49 -0) 📝 `management/server/geolocation/geolocation.go` (+2 -7) 📝 `management/server/geolocation/geolocation_test.go` (+2 -4) 📝 `management/server/grpcserver.go` (+9 -8) 📝 `management/server/http/api/openapi.yml` (+12 -0) 📝 `management/server/http/api/types.gen.go` (+27 -0) 📝 `management/server/http/peers_handler.go` (+17 -0) 📝 `management/server/mock_server/account_mock.go` (+4 -3) 📝 `management/server/peer.go` (+19 -1) 📝 `management/server/peer/peer.go` (+11 -6) 📝 `management/server/posture/geo_location.go` (+2 -2) 📝 `management/server/posture/geo_location_test.go` (+24 -40) 📝 `management/server/sqlite_store.go` (+12 -0) 📝 `management/server/sqlite_store_test.go` (+43 -0) 📝 `management/server/store.go` (+1 -0) </details> ### 📄 Description ## Describe your changes This PR uses the geolocation service to resolve IP to location. The lookup happens once on the first connection - when a client calls the Sync procedure. The location is stored as part of the peer: ```go type Location struct { ConnectionIP net.IP CountryCode string CityName string GeoNameID uint } ``` ## Issue ticket number and link ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] 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:07:48 -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#15499