disco: remove unused code

This commit is contained in:
rkonfj
2024-07-20 09:03:40 +08:00
parent 7de639ba01
commit 7f6c78b763
2 changed files with 2 additions and 8 deletions

View File

@@ -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
}

View File

@@ -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()