]> Sergey Matveev's repositories - btrtrc.git/commitdiff
go1.19 compatibility
authorMatt Joiner <anacrolix@gmail.com>
Tue, 23 May 2023 10:55:30 +0000 (20:55 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 23 May 2023 10:55:30 +0000 (20:55 +1000)
netip-addrport.go
peer_protocol/handshake.go
peer_protocol/ut-holepunch/ut-holepunch.go
pexconn.go

index a57ea2067070a4f71668e1491bceada232f949aa..e438db7085f446c473a31c74f75dbd167fba6f67 100644 (file)
@@ -17,7 +17,7 @@ func ipv4AddrPortFromKrpcNodeAddr(na krpc.NodeAddr) (_ netip.AddrPort, err error
                err = fmt.Errorf("not an ipv4 address: %v", na.IP)
                return
        }
-       addr := netip.AddrFrom4([4]byte(ip4))
+       addr := netip.AddrFrom4(*(*[4]byte)(ip4))
        addrPort := netip.AddrPortFrom(addr, uint16(na.Port))
        return addrPort, nil
 }
@@ -28,7 +28,7 @@ func ipv6AddrPortFromKrpcNodeAddr(na krpc.NodeAddr) (_ netip.AddrPort, err error
                err = fmt.Errorf("not an ipv4 address: %v", na.IP)
                return
        }
-       addr := netip.AddrFrom16([16]byte(ip6))
+       addr := netip.AddrFrom16(*(*[16]byte)(ip6))
        addrPort := netip.AddrPortFrom(addr, uint16(na.Port))
        return addrPort, nil
 }
index 454cc2460bb90a206ffab9eb9fcba0dfa485dc77..a6f648cfe6e16ea3a6b147dd8bd5490a14c57022 100644 (file)
@@ -70,7 +70,7 @@ func (pex PeerExtensionBits) String() string {
                        pex.SetBit(bitTag.bit, false)
                }
        }
-       unknownCount := bits.OnesCount64(*(*uint64)((unsafe.Pointer(unsafe.SliceData(pex[:])))))
+       unknownCount := bits.OnesCount64(*(*uint64)((unsafe.Pointer(&pex[0]))))
        if unknownCount != 0 {
                tags = append(tags, fmt.Sprintf("%v unknown", unknownCount))
        }
index f7a586a632870a173c60a082007b963b2d066a8b..3051fc0483d82df0de5e94df132ac3aaee61cd2d 100644 (file)
@@ -54,13 +54,13 @@ func (m *Msg) UnmarshalBinary(b []byte) error {
        var addr netip.Addr
        switch addrType {
        case Ipv4:
-               addr = netip.AddrFrom4([4]byte(b[:4]))
+               addr = netip.AddrFrom4(*(*[4]byte)(b[:4]))
                b = b[4:]
        case Ipv6:
                if len(b) < 22 {
                        return fmt.Errorf("not enough bytes")
                }
-               addr = netip.AddrFrom16([16]byte(b[:16]))
+               addr = netip.AddrFrom16(*(*[16]byte)(b[:16]))
                b = b[16:]
        default:
                return fmt.Errorf("unhandled addr type value %v", addrType)
index cc6c3fc679dbbd50cc4dd7c2c57448c7f06dd59d..459131f416de3de189241c90c9fb67ed5e5ce259 100644 (file)
@@ -108,13 +108,13 @@ func (s *pexConnState) updateRemoteLiveConns(rx pp.PexMsg) (errs []error) {
                delete(s.remoteLiveConns, addrPort)
        }
        for i, added := range rx.Added {
-               addr := netip.AddrFrom4([4]byte(added.IP.To4()))
+               addr := netip.AddrFrom4(*(*[4]byte)(added.IP.To4()))
                addrPort := netip.AddrPortFrom(addr, uint16(added.Port))
                flags := g.SliceGet(rx.AddedFlags, i)
                g.MakeMapIfNilAndSet(&s.remoteLiveConns, addrPort, flags)
        }
        for i, added := range rx.Added6 {
-               addr := netip.AddrFrom16([16]byte(added.IP.To16()))
+               addr := netip.AddrFrom16(*(*[16]byte)(added.IP.To16()))
                addrPort := netip.AddrPortFrom(addr, uint16(added.Port))
                flags := g.SliceGet(rx.Added6Flags, i)
                g.MakeMapIfNilAndSet(&s.remoteLiveConns, addrPort, flags)