mirror of
https://github.com/sigcn/pg.git
synced 2025-09-27 20:22:20 +08:00
disco: remove unused code
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user