-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from mfreeman451/updates/support_multi_networ…
…k_scanner Updates/support multi network scanner
- Loading branch information
Showing
15 changed files
with
424 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
VERSION=${VERSION:-1.0.9} | ||
VERSION=${VERSION:-1.0.10} | ||
|
||
|
||
./setup-deb-poller.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package agent | ||
|
||
import ( | ||
"net" | ||
) | ||
|
||
// IPSorter is a type for sorting IP addresses. | ||
type IPSorter []string | ||
|
||
func (s IPSorter) Len() int { return len(s) } | ||
|
||
func (s IPSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] } | ||
|
||
func (s IPSorter) Less(i, j int) bool { | ||
ip1 := net.ParseIP(s[i]) | ||
ip2 := net.ParseIP(s[j]) | ||
|
||
// Handle nil cases (invalid IPs) by falling back to string comparison | ||
if ip1 == nil || ip2 == nil { | ||
return s[i] < s[j] | ||
} | ||
|
||
// Convert to 4-byte representation for IPv4 | ||
ip1 = ip1.To4() | ||
ip2 = ip2.To4() | ||
|
||
if ip1 == nil || ip2 == nil { | ||
return s[i] < s[j] | ||
} | ||
|
||
// Compare each byte | ||
for i := 0; i < 4; i++ { | ||
if ip1[i] != ip2[i] { | ||
return ip1[i] < ip2[i] | ||
} | ||
} | ||
|
||
return false | ||
} |
Oops, something went wrong.