mirror of
https://git.vectorsigma.ru/public/k3s.git
synced 2026-08-02 13:19:48 +00:00
Refactor egress-selector pods mode to watch pods
Watching pods appears to be the most reliable way to ensure that the proxy routes and authorizes connections. Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
committed by
Brad Davidson
parent
8456d98283
commit
15b8fb962a
@@ -256,3 +256,26 @@ func IsIPv6OnlyCIDRs(cidrs []*net.IPNet) (bool, error) {
|
||||
|
||||
return !v4Found && v6Found, nil
|
||||
}
|
||||
|
||||
// IPToIPNet converts an IP to an IPNet, using a fully filled mask appropriate for the address family.
|
||||
func IPToIPNet(ip net.IP) (*net.IPNet, error) {
|
||||
address := ip.String()
|
||||
if strings.Contains(address, ":") {
|
||||
address += "/128"
|
||||
} else {
|
||||
address += "/32"
|
||||
}
|
||||
_, cidr, err := net.ParseCIDR(address)
|
||||
return cidr, err
|
||||
}
|
||||
|
||||
// IPStringToIPNet converts an IP string to an IPNet, using a fully filled mask appropriate for the address family.
|
||||
func IPStringToIPNet(address string) (*net.IPNet, error) {
|
||||
if strings.Contains(address, ":") {
|
||||
address += "/128"
|
||||
} else {
|
||||
address += "/32"
|
||||
}
|
||||
_, cidr, err := net.ParseCIDR(address)
|
||||
return cidr, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user