
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
github.com/vikrammel/golang-ipsorting
git clone into ~/go/src
or download .go
files and place in ~/go/src/ipsorting
:
git clone https://github.com/Vikrammel/golang-ipsorting.git
if vendoring, place .go
files in <projectroot>/app/vendor/ipsorting
import package in code:
import (
"ipsorting"
)
use on string or an array/slice of strings of ip:ports (ipsorting.go can be easily modified to work with just IPs instead of IP:Port)
compare two IP:Ports
sortedPair := ipsorting.OrderIPPair("10.0.0.14:8080", "10.0.0.14:5060")
//sortedPair is now a string array literal of size 2 of the two ip:port strings passed in
//in ascending numerical order
log.Println(sortedPair[0])
//10.0.0.14:5060
sort a slice of IP:Ports
//unsortedList = ["10.0.0.24:8080", "10.0.0.21:8080", "10.0.0.22:8080", "10.0.0.23:8080"]
sortedList := ipsorting.SortIPs(unsortedList)
log.Println(sortedList)
//["10.0.0.21:8080", "10.0.0.22:8080", "10.0.0.23:8080", "10.0.0.24:8080"]
//ports do not need to be the same, they will also be compared
//adapted quickSort, avg complexity = O(nlog(n)), worst case = O(n^2)
insert IP:Port into slice in correct position
//sortedList = ["10.0.0.21:8080", "10.0.0.22:8080", "10.0.0.23:8080", "10.0.0.24:8080"]
sortedList = ipsorting.InsortIP(sortedList, "10.0.0.23:8070")
log.Println(sortedList)
//["10.0.0.21:8080", "10.0.0.22:8080", "10.0.0.23:8070", "10.0.0.23:8080", "10.0.0.24:8080"]
//adapted binarySearch, complexity = O(log(n))
Binary Search [for InsortIP()]
Feel free to use this in any of your projects and please let me know if you encounter any bugs. Thank you.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.