[PR #6553] [management] expose peer MAC addresses and make peers searchable by MAC #26129

Open
opened 2026-08-05 07:06:55 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6553
Author: @a-elkaim
Created: 6/26/2026
Status: 🔄 Open

Base: mainHead: feat/search-peers-by-mac


📝 Commits (1)

  • ef7d516 [management] expose peer MAC addresses and make peers searchable by MAC

📊 Changes

21 files changed (+146 additions, -46 deletions)

View changed files

📝 management/internals/controllers/network_map/controller/repository.go (+1 -1)
📝 management/internals/modules/peers/manager.go (+1 -1)
📝 management/server/account.go (+5 -5)
📝 management/server/account/manager.go (+1 -1)
📝 management/server/account/manager_mock.go (+4 -4)
📝 management/server/account_test.go (+9 -9)
📝 management/server/http/handlers/accounts/accounts_handler.go (+1 -1)
📝 management/server/http/handlers/groups/groups_handler.go (+5 -5)
📝 management/server/http/handlers/groups/groups_handler_test.go (+1 -1)
📝 management/server/http/handlers/peers/peers_handler.go (+15 -1)
📝 management/server/http/handlers/peers/peers_handler_test.go (+1 -1)
📝 management/server/integrated_validator.go (+1 -1)
📝 management/server/mock_server/account_mock.go (+3 -3)
📝 management/server/peer.go (+2 -2)
📝 management/server/peer_test.go (+2 -2)
📝 management/server/store/sql_store.go (+6 -1)
📝 management/server/store/sql_store_test.go (+44 -2)
📝 management/server/store/store.go (+1 -1)
📝 management/server/store/store_mock.go (+4 -4)
📝 shared/management/http/api/openapi.yml (+24 -0)

...and 1 more files

📄 Description

Peers already store per-interface MAC addresses in meta_network_addresses, but they were neither returned by the peers API nor searchable.

Add a network_addresses field (net_ip + mac) to the Peer/PeerBatch responses and a dedicated mac query parameter on GET /api/peers that matches the MAC JSON column, enabling GET /api/peers?mac=<mac> and dashboard search by MAC.

Describe your changes

Peers collect their per-interface MAC addresses (stored in the meta_network_addresses column), but they were never returned by the peers API nor usable for filtering. This exposes them and lets peers be searched by MAC.

  • API response: added a network_addresses field (array of { net_ip, mac })
    to the Peer schema, returned on both GET /api/peers (PeerBatch) and
    GET /api/peers/{id}.
  • New filter: added a mac query parameter to GET /api/peers, alongside
    the existing name / ip parameters. It does a server-side substring match
    against the stored network addresses, e.g. GET /api/peers?mac=00:93:37.
  • Threaded macFilter through AccountManager.GetPeers and
    Store.GetAccountPeers, regenerated the OpenAPI types, and updated the mocks.
  • Added a store test (TestSqlStore_GetAccountPeers_FilterByMac) covering full
    MAC, prefix, and no-match cases.

Example response entry:

"network_addresses": [
  { "net_ip": "192.168.0.11/24", "mac": "00:93:37:bd:83:0f" }
]

Slack discussion: https://netbirdio.slack.com/archives/C02KHAE8VLZ/p1782489164474579

Stack

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)
  • [x ] This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

Discussion thread: https://netbirdio.slack.com/archives/C02KHAE8VLZ/p1782489164474579

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

The REST API reference is generated from shared/management/http/api/openapi.yml, which this PR updates (new mac parameter + network_addresses schema). No separate prose docs change is required.

Docs PR URL (required if "docs added" is checked)

N/A

Summary by CodeRabbit

  • New Features

    • Added MAC address filtering to peer search and listing.
    • Peer details and peer list items now include network address information.
    • The peers API now supports a new optional MAC filter parameter.
  • Bug Fixes

    • Improved peer-related operations so account peer lookups handle the expanded filtering and network address data consistently.

🔄 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/6553 **Author:** [@a-elkaim](https://github.com/a-elkaim) **Created:** 6/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/search-peers-by-mac` --- ### 📝 Commits (1) - [`ef7d516`](https://github.com/netbirdio/netbird/commit/ef7d516b5337ba6df33f7f662c0d67c55f5de418) [management] expose peer MAC addresses and make peers searchable by MAC ### 📊 Changes **21 files changed** (+146 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `management/internals/controllers/network_map/controller/repository.go` (+1 -1) 📝 `management/internals/modules/peers/manager.go` (+1 -1) 📝 `management/server/account.go` (+5 -5) 📝 `management/server/account/manager.go` (+1 -1) 📝 `management/server/account/manager_mock.go` (+4 -4) 📝 `management/server/account_test.go` (+9 -9) 📝 `management/server/http/handlers/accounts/accounts_handler.go` (+1 -1) 📝 `management/server/http/handlers/groups/groups_handler.go` (+5 -5) 📝 `management/server/http/handlers/groups/groups_handler_test.go` (+1 -1) 📝 `management/server/http/handlers/peers/peers_handler.go` (+15 -1) 📝 `management/server/http/handlers/peers/peers_handler_test.go` (+1 -1) 📝 `management/server/integrated_validator.go` (+1 -1) 📝 `management/server/mock_server/account_mock.go` (+3 -3) 📝 `management/server/peer.go` (+2 -2) 📝 `management/server/peer_test.go` (+2 -2) 📝 `management/server/store/sql_store.go` (+6 -1) 📝 `management/server/store/sql_store_test.go` (+44 -2) 📝 `management/server/store/store.go` (+1 -1) 📝 `management/server/store/store_mock.go` (+4 -4) 📝 `shared/management/http/api/openapi.yml` (+24 -0) _...and 1 more files_ </details> ### 📄 Description Peers already store per-interface MAC addresses in meta_network_addresses, but they were neither returned by the peers API nor searchable. Add a network_addresses field (net_ip + mac) to the Peer/PeerBatch responses and a dedicated `mac` query parameter on GET /api/peers that matches the MAC JSON column, enabling `GET /api/peers?mac=<mac>` and dashboard search by MAC. ## Describe your changes Peers collect their per-interface MAC addresses (stored in the `meta_network_addresses` column), but they were never returned by the peers API nor usable for filtering. This exposes them and lets peers be searched by MAC. - **API response:** added a `network_addresses` field (array of `{ net_ip, mac }`) to the `Peer` schema, returned on both `GET /api/peers` (PeerBatch) and `GET /api/peers/{id}`. - **New filter:** added a `mac` query parameter to `GET /api/peers`, alongside the existing `name` / `ip` parameters. It does a server-side substring match against the stored network addresses, e.g. `GET /api/peers?mac=00:93:37`. - Threaded `macFilter` through `AccountManager.GetPeers` and `Store.GetAccountPeers`, regenerated the OpenAPI types, and updated the mocks. - Added a store test (`TestSqlStore_GetAccountPeers_FilterByMac`) covering full MAC, prefix, and no-match cases. Example response entry: ```json "network_addresses": [ { "net_ip": "192.168.0.11/24", "mac": "00:93:37:bd:83:0f" } ] ``` ## Issue ticket number and link Slack discussion: https://netbirdio.slack.com/archives/C02KHAE8VLZ/p1782489164474579 ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [x ] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). Discussion thread: https://netbirdio.slack.com/archives/C02KHAE8VLZ/p1782489164474579 > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) The REST API reference is generated from `shared/management/http/api/openapi.yml`, which this PR updates (new `mac` parameter + `network_addresses` schema). No separate prose docs change is required. ### Docs PR URL (required if "docs added" is checked) N/A <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added MAC address filtering to peer search and listing. * Peer details and peer list items now include network address information. * The peers API now supports a new optional MAC filter parameter. * **Bug Fixes** * Improved peer-related operations so account peer lookups handle the expanded filtering and network address data consistently. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <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 07:06:55 -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#26129