Servers updater (#232)
* Support for all VPN providers * Update all VPN providers servers information * Remove old tooling binaries
This commit is contained in:
24
internal/updater/ips.go
Normal file
24
internal/updater/ips.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package updater
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func uniqueSortedIPs(ips []net.IP) []net.IP {
|
||||
uniqueIPs := make(map[string]struct{})
|
||||
for _, ip := range ips {
|
||||
uniqueIPs[ip.String()] = struct{}{}
|
||||
}
|
||||
ips = make([]net.IP, len(uniqueIPs))
|
||||
i := 0
|
||||
for ip := range uniqueIPs {
|
||||
ips[i] = net.ParseIP(ip)
|
||||
i++
|
||||
}
|
||||
sort.Slice(ips, func(i, j int) bool {
|
||||
return bytes.Compare(ips[i], ips[j]) < 0
|
||||
})
|
||||
return ips
|
||||
}
|
||||
Reference in New Issue
Block a user