diff --git a/server/scan/scanner.go b/server/scan/scanner.go index 8b1e3f0..0b19135 100644 --- a/server/scan/scanner.go +++ b/server/scan/scanner.go @@ -18,11 +18,17 @@ const timeoutTCPHosts = time.Duration(1) * time.Second func nextIP(ip net.IP) (next net.IP) { // FIXME Proper next IP address in network calculation - next = make([]byte, 4) - bytes := []byte(ip) - bytes = bytes[len(bytes)-4:] - next[0], next[1], next[2], next[3] = bytes[0], bytes[1], bytes[2], bytes[3]+1 - return + + ip = ip.To4() + o := (uint(ip[0]) << 24) + (uint(ip[1]) << 16) + (uint(ip[2]) << 8) + uint(ip[3]) + o++ + o3 := byte(o & 0xFF) + o2 := byte((o >> 8) & 0xFF) + o1 := byte((o >> 16) & 0xFF) + o0 := byte((o >> 24) & 0xFF) + + return net.IPv4(o0, o1, o2, o3) + } // AvailableNetworks returns all IPv4 networks that are available to the host