InterfaceNetworks returns CIDR prefixes parsed from the node's core `address` list. Used to restrict peer AllowedIPs to subnets this interface actually serves.
()
| 84 | // InterfaceNetworks returns CIDR prefixes parsed from the node's core `address` list. |
| 85 | // Used to restrict peer AllowedIPs to subnets this interface actually serves. |
| 86 | func (c *Config) InterfaceNetworks() []*net.IPNet { |
| 87 | if c == nil { |
| 88 | return nil |
| 89 | } |
| 90 | var out []*net.IPNet |
| 91 | for _, addr := range c.Address { |
| 92 | addr = strings.TrimSpace(addr) |
| 93 | if addr == "" { |
| 94 | continue |
| 95 | } |
| 96 | _, ipNet, err := net.ParseCIDR(addr) |
| 97 | if err != nil { |
| 98 | continue |
| 99 | } |
| 100 | out = append(out, ipNet) |
| 101 | } |
| 102 | return out |
| 103 | } |
| 104 | |
| 105 | // GetPrivateKey returns the parsed WireGuard private key. |
| 106 | // The parsed key is stored in memory and reused after first successful parse. |
no outgoing calls