calculate WG peer connection status

This commit is contained in:
Pavel Sviderski
2024-10-07 14:58:21 +10:00
parent 5094149406
commit 7b98ed34df
3 changed files with 181 additions and 37 deletions
+12
View File
@@ -84,3 +84,15 @@ func (c Config) toDeviceConfig() (wgtypes.Config, error) {
Peers: wgPeerConfigs,
}, nil
}
func (p *PeerConfig) prefixes() ([]netip.Prefix, error) {
managePrefix, err := addrToSingleIPPrefix(p.ManagementIP)
if err != nil {
return nil, fmt.Errorf("parse management IP: %w", err)
}
prefixes := []netip.Prefix{managePrefix}
if p.Subnet != nil {
prefixes = append(prefixes, *p.Subnet)
}
return prefixes, nil
}