Skip to content

Commit

Permalink
[support/network] Sort and deduplicate IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed May 6, 2024
1 parent 1c19686 commit 049cd88
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### 12.123.1

- `[support/network]` Sort and deduplicate IPs

### 12.123.0

- `[csv]` Added method `Reader.Line`
Expand Down
2 changes: 1 addition & 1 deletion ek.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "12.123.0"
const VERSION = "12.123.1"

// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down
8 changes: 8 additions & 0 deletions support/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (

"github.com/essentialkaos/ek/v12/netutil"
"github.com/essentialkaos/ek/v12/req"
"github.com/essentialkaos/ek/v12/sliceutil"
"github.com/essentialkaos/ek/v12/sortutil"

"github.com/essentialkaos/ek/v12/support"
)
Expand All @@ -29,6 +31,12 @@ func Collect(ipResolverURL ...string) *support.NetworkInfo {
IPv6: cleanIPList(netutil.GetAllIP6()),
}

sortutil.StringsNatural(info.IPv4)
sortutil.StringsNatural(info.IPv6)

info.IPv4 = sliceutil.Deduplicate(info.IPv4)
info.IPv6 = sliceutil.Deduplicate(info.IPv6)

info.Hostname, _ = os.Hostname()

if len(ipResolverURL) != 0 {
Expand Down

0 comments on commit 049cd88

Please sign in to comment.