Skip to content

Commit

Permalink
fix: API server cert/CIDR parsing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jpts committed Sep 4, 2023
1 parent 938d701 commit 8218a1c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ func getAPIServerCIDRS() ([]*net.IPNet, error) {

var cidrs []*net.IPNet
for _, ip := range cert.IPAddresses {
cidrs = append(cidrs, &net.IPNet{
IP: ip,
// Take a best guess here
Mask: net.IPv4Mask(255, 255, 252, 0),
})
// Guess subnet size
_, net, err := net.ParseCIDR(fmt.Sprintf("%s/22", ip.String()))
if err != nil {
return nil, fmt.Errorf("problem parsing apiserver cert IPs: %s", ip)
}
cidrs = append(cidrs, net)
}

return cidrs, nil
Expand Down

0 comments on commit 8218a1c

Please sign in to comment.