go1.19 compatibility
This commit is contained in:
parent
a8ab0baec8
commit
b18e824a6b
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue