implement uncloudd daemon that starts a WireGuard network without peer probing

This commit is contained in:
Pavel Sviderski
2024-08-26 17:09:54 +10:00
parent 222edb7647
commit e074b6855f
13 changed files with 347 additions and 145 deletions
+18
View File
@@ -0,0 +1,18 @@
package network
import (
"net"
"net/netip"
)
// MachineIP returns the IP address of the machine which is the first address in the subnet.
func MachineIP(subnet netip.Prefix) netip.Addr {
return subnet.Masked().Addr().Next()
}
func prefixToIPNet(prefix netip.Prefix) net.IPNet {
return net.IPNet{
IP: prefix.Addr().AsSlice(),
Mask: net.CIDRMask(prefix.Bits(), prefix.Addr().BitLen()),
}
}