]> Sergey Matveev's repositories - btrtrc.git/blobdiff - bep40.go
Drop support for go 1.20
[btrtrc.git] / bep40.go
index fa696bdac57233917e868cc40e2664ebb00b09ac..9a643553d730e2a6b408ea37a7eb6ec4af558c4b 100644 (file)
--- a/bep40.go
+++ b/bep40.go
@@ -13,11 +13,6 @@ var table = crc32.MakeTable(crc32.Castagnoli)
 
 type peerPriority = uint32
 
-type ipPort struct {
-       IP   net.IP
-       Port uint16
-}
-
 func sameSubnet(ones, bits int, a, b net.IP) bool {
        mask := net.CIDRMask(ones, bits)
        return a.Mask(mask).Equal(b.Mask(mask))
@@ -53,7 +48,7 @@ func ipv6Mask(a, b net.IP) net.IPMask {
        panic(fmt.Sprintf("%s %s", a, b))
 }
 
-func bep40PriorityBytes(a, b ipPort) ([]byte, error) {
+func bep40PriorityBytes(a, b IpPort) ([]byte, error) {
        if a.IP.Equal(b.IP) {
                var ret [4]byte
                binary.BigEndian.PutUint16(ret[0:2], a.Port)
@@ -71,7 +66,7 @@ func bep40PriorityBytes(a, b ipPort) ([]byte, error) {
        return nil, errors.New("incomparable IPs")
 }
 
-func bep40Priority(a, b ipPort) (peerPriority, error) {
+func bep40Priority(a, b IpPort) (peerPriority, error) {
        bs, err := bep40PriorityBytes(a, b)
        if err != nil {
                return 0, err
@@ -84,7 +79,7 @@ func bep40Priority(a, b ipPort) (peerPriority, error) {
        return crc32.Checksum(bs, table), nil
 }
 
-func bep40PriorityIgnoreError(a, b ipPort) peerPriority {
+func bep40PriorityIgnoreError(a, b IpPort) peerPriority {
        prio, _ := bep40Priority(a, b)
        return prio
 }