mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-13 12:19:54 +00:00
* [client] iOS: structured ResolvedIPs collection for domain routes Replace comma-joined ResolvedIPs string with a gomobile-friendly ResolvedIPs collection (Add/Get/Size), mirroring the Android bridge in client/android/network_domains.go. This allows the iOS app to match domain-route resolved IPs against connected peer routes without parsing CSV strings, fixing the route status indicator for dynamic (DNS) routes. * [client] iOS: align dynamic route exposure with Android bridge For dynamic (DNS) routes the Swift side previously received "invalid Prefix" as the Network value, forcing UI code to special-case that sentinel. The Android bridge uses Domains.SafeString() instead so peer.routes entries (which also derive from Domains.SafeString()) match directly. Mirror that here. Also fix the resolved IP lookup: resolvedDomains is keyed by the resolved domain (e.g. api.ipify.org), not the configured pattern (e.g. *.ipify.org). Group entries by ParentDomain like the daemon does in client/server/network.go, so wildcard route patterns get their resolved IPs populated.
95 lines
1.8 KiB
Go
95 lines
1.8 KiB
Go
//go:build ios
|
|
|
|
package NetBirdSDK
|
|
|
|
// RoutesSelectionInfoCollection made for Java layer to get non default types as collection
|
|
type RoutesSelectionInfoCollection interface {
|
|
Add(s string) RoutesSelectionInfoCollection
|
|
Get(i int) string
|
|
Size() int
|
|
}
|
|
|
|
type RoutesSelectionDetails struct {
|
|
All bool
|
|
Append bool
|
|
items []RoutesSelectionInfo
|
|
}
|
|
|
|
type RoutesSelectionInfo struct {
|
|
ID string
|
|
Network string
|
|
Domains *DomainDetails
|
|
Selected bool
|
|
}
|
|
|
|
type DomainCollection interface {
|
|
Add(s DomainInfo) DomainCollection
|
|
Get(i int) *DomainInfo
|
|
Size() int
|
|
}
|
|
|
|
type DomainDetails struct {
|
|
items []DomainInfo
|
|
}
|
|
|
|
type DomainInfo struct {
|
|
Domain string
|
|
resolvedIPs ResolvedIPs
|
|
}
|
|
|
|
func (d *DomainInfo) AddResolvedIP(ipAddress string) {
|
|
d.resolvedIPs.Add(ipAddress)
|
|
}
|
|
|
|
func (d *DomainInfo) GetResolvedIPs() *ResolvedIPs {
|
|
return &d.resolvedIPs
|
|
}
|
|
|
|
type ResolvedIPs struct {
|
|
items []string
|
|
}
|
|
|
|
func (r *ResolvedIPs) Add(ipAddress string) {
|
|
r.items = append(r.items, ipAddress)
|
|
}
|
|
|
|
func (r *ResolvedIPs) Get(i int) string {
|
|
if i < 0 || i >= len(r.items) {
|
|
return ""
|
|
}
|
|
return r.items[i]
|
|
}
|
|
|
|
func (r *ResolvedIPs) Size() int {
|
|
return len(r.items)
|
|
}
|
|
|
|
// Add new PeerInfo to the collection
|
|
func (array RoutesSelectionDetails) Add(s RoutesSelectionInfo) RoutesSelectionDetails {
|
|
array.items = append(array.items, s)
|
|
return array
|
|
}
|
|
|
|
// Get return an element of the collection
|
|
func (array RoutesSelectionDetails) Get(i int) *RoutesSelectionInfo {
|
|
return &array.items[i]
|
|
}
|
|
|
|
// Size return with the size of the collection
|
|
func (array RoutesSelectionDetails) Size() int {
|
|
return len(array.items)
|
|
}
|
|
|
|
func (array DomainDetails) Add(s DomainInfo) DomainCollection {
|
|
array.items = append(array.items, s)
|
|
return array
|
|
}
|
|
|
|
func (array DomainDetails) Get(i int) *DomainInfo {
|
|
return &array.items[i]
|
|
}
|
|
|
|
func (array DomainDetails) Size() int {
|
|
return len(array.items)
|
|
}
|