mirror of
https://github.com/netbirdio/netbird.git
synced 2026-03-31 06:34:14 -04:00
* Simplify Android ConnStatus API with integer constants Replace dual field PeerInfo design with unified integer based ConnStatus field and exported gomobile friendly constants. Changes: > PeerInfo.ConnStatus: changed from string to int > Export three constants: ConnStatusIdle, ConnStatusConnecting,ConnStatusConnected (mapped to peer.ConnStatus enum values) > Updated PeersList() to convert peer enum directly to int Benefits: > Simpler API surface with single ConnStatus field > Better gomobile compatibility for cross-platform usage > Type-safe integer constants across language boundaries * test: add All group to setupTestAccount fixture The setupTestAccount() test helper was missing the required "All" group, causing "failed to get group all: no group ALL found" errors during test execution. Add the All group with all test peers to match the expected account structure. Fixes the failing account and types package tests when GetGroupAll() is called in test scenarios.
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
//go:build android
|
|
|
|
package android
|
|
|
|
import "github.com/netbirdio/netbird/client/internal/peer"
|
|
|
|
// Connection status constants exported via gomobile.
|
|
const (
|
|
ConnStatusIdle = int(peer.StatusIdle)
|
|
ConnStatusConnecting = int(peer.StatusConnecting)
|
|
ConnStatusConnected = int(peer.StatusConnected)
|
|
)
|
|
|
|
// PeerInfo describe information about the peers. It designed for the UI usage
|
|
type PeerInfo struct {
|
|
IP string
|
|
FQDN string
|
|
ConnStatus int
|
|
Routes PeerRoutes
|
|
}
|
|
|
|
func (p *PeerInfo) GetPeerRoutes() *PeerRoutes {
|
|
return &p.Routes
|
|
}
|
|
|
|
// PeerInfoArray is a wrapper of []PeerInfo
|
|
type PeerInfoArray struct {
|
|
items []PeerInfo
|
|
}
|
|
|
|
// Add new PeerInfo to the collection
|
|
func (array *PeerInfoArray) Add(s PeerInfo) *PeerInfoArray {
|
|
array.items = append(array.items, s)
|
|
return array
|
|
}
|
|
|
|
// Get return an element of the collection
|
|
func (array *PeerInfoArray) Get(i int) *PeerInfo {
|
|
return &array.items[i]
|
|
}
|
|
|
|
// Size return with the size of the collection
|
|
func (array *PeerInfoArray) Size() int {
|
|
return len(array.items)
|
|
}
|