p2p: fix sharedUDPConn

This commit is contained in:
Felix Lange 2024-05-26 12:02:51 +02:00
parent e0529692ca
commit 262fe00377

View file

@ -24,6 +24,7 @@ import (
"errors"
"fmt"
"net"
"net/netip"
"slices"
"sync"
"sync/atomic"
@ -436,10 +437,10 @@ type sharedUDPConn struct {
}
// ReadFromUDP implements discover.UDPConn
func (s *sharedUDPConn) ReadFromUDP(b []byte) (n int, addr *net.UDPAddr, err error) {
func (s *sharedUDPConn) ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error) {
packet, ok := <-s.unhandled
if !ok {
return 0, nil, errors.New("connection was closed")
return 0, netip.AddrPort{}, errors.New("connection was closed")
}
l := len(packet.Data)
if l > len(b) {