diff --git a/disco/udp.go b/disco/udp.go index 0776ba7..0145e05 100644 --- a/disco/udp.go +++ b/disco/udp.go @@ -31,7 +31,6 @@ type UDPConfig struct { DisableIPv4 bool DisableIPv6 bool ID peer.ID - NetworkDetectInterval time.Duration PeerKeepaliveInterval time.Duration DiscoMagic func() []byte } @@ -503,9 +502,6 @@ func ListenUDP(cfg UDPConfig) (*UDPConn, error) { if cfg.ID.Len() == 0 { return nil, errors.New("peer id is required") } - if cfg.NetworkDetectInterval < time.Second { - cfg.NetworkDetectInterval = 5 * time.Second - } if cfg.PeerKeepaliveInterval < time.Second { cfg.PeerKeepaliveInterval = 10 * time.Second } diff --git a/p2p/conn.go b/p2p/conn.go index 7d35ba6..49d5866 100644 --- a/p2p/conn.go +++ b/p2p/conn.go @@ -99,10 +99,7 @@ func (c *PeerPacketConn) Close() error { if err := c.udpConn.Close(); err != nil { errs = append(errs, err) } - if len(errs) > 0 { - return errors.Join(errs...) - } - return nil + return errors.Join(errs...) } // LocalAddr returns the local network address, if known. @@ -214,6 +211,7 @@ func (c *PeerPacketConn) SharedKey(peerID peer.ID) ([]byte, error) { return c.cfg.SymmAlgo.SecretKey()(peerID.String()) } +// runAddrUpdateEventLoop listen network change and restart udp and websocket listener func (c *PeerPacketConn) runAddrUpdateEventLoop() { ctx, cancel := context.WithCancel(context.Background()) defer cancel()