🦈🏠🐜 Initial Commit 🐜🦈🏠

This commit is contained in:
Jason
2022-02-14 16:45:10 -05:00
commit 964ab574ea
23 changed files with 2384 additions and 0 deletions

27
iputil/iputil_test.go Normal file
View File

@@ -0,0 +1,27 @@
package iputil
import (
"math/big"
"net"
"testing"
)
func TestToDecimal(t *testing.T) {
var msb = new(big.Int)
msb, _ = msb.SetString("80000000000000000000000000000000", 16)
var tests = []struct {
in string
out *big.Int
}{
{"127.0.0.1", big.NewInt(2130706433)},
{"::1", big.NewInt(1)},
{"8000::", msb},
}
for _, tt := range tests {
i := ToDecimal(net.ParseIP(tt.in))
if tt.out.Cmp(i) != 0 {
t.Errorf("Expected %d, got %d for IP %s", tt.out, i, tt.in)
}
}
}