Skip to content

Commit 90a49cb

Browse files
authored
Don't crash when private IP netmask is 255.255.255.255 (#297)
1 parent 79d76aa commit 90a49cb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

configurer/linux.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ func (l Linux) PrivateAddress(h os.Host, iface, publicip string) (string, error)
175175
if len(items) < 4 {
176176
continue
177177
}
178-
addr := items[3][:strings.Index(items[3], "/")]
178+
// When subnet mask is 255.255.255.255, CIDR notation is not /32, but it is omitted instead.
179+
index := strings.Index(items[3], "/")
180+
addr := items[3]
181+
if index >= 0 {
182+
addr = items[3][:index]
183+
}
179184
if len(strings.Split(addr, ".")) == 4 {
180185
if publicip != addr {
181186
return addr, nil

0 commit comments

Comments
 (0)