mirror of
https://github.com/sigcn/pg.git
synced 2025-10-03 12:46:25 +08:00
disco: remove unused code
This commit is contained in:
@@ -31,7 +31,6 @@ type UDPConfig struct {
|
|||||||
DisableIPv4 bool
|
DisableIPv4 bool
|
||||||
DisableIPv6 bool
|
DisableIPv6 bool
|
||||||
ID peer.ID
|
ID peer.ID
|
||||||
NetworkDetectInterval time.Duration
|
|
||||||
PeerKeepaliveInterval time.Duration
|
PeerKeepaliveInterval time.Duration
|
||||||
DiscoMagic func() []byte
|
DiscoMagic func() []byte
|
||||||
}
|
}
|
||||||
@@ -503,9 +502,6 @@ func ListenUDP(cfg UDPConfig) (*UDPConn, error) {
|
|||||||
if cfg.ID.Len() == 0 {
|
if cfg.ID.Len() == 0 {
|
||||||
return nil, errors.New("peer id is required")
|
return nil, errors.New("peer id is required")
|
||||||
}
|
}
|
||||||
if cfg.NetworkDetectInterval < time.Second {
|
|
||||||
cfg.NetworkDetectInterval = 5 * time.Second
|
|
||||||
}
|
|
||||||
if cfg.PeerKeepaliveInterval < time.Second {
|
if cfg.PeerKeepaliveInterval < time.Second {
|
||||||
cfg.PeerKeepaliveInterval = 10 * time.Second
|
cfg.PeerKeepaliveInterval = 10 * time.Second
|
||||||
}
|
}
|
||||||
|
@@ -99,10 +99,7 @@ func (c *PeerPacketConn) Close() error {
|
|||||||
if err := c.udpConn.Close(); err != nil {
|
if err := c.udpConn.Close(); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
if len(errs) > 0 {
|
return errors.Join(errs...)
|
||||||
return errors.Join(errs...)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalAddr returns the local network address, if known.
|
// 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())
|
return c.cfg.SymmAlgo.SecretKey()(peerID.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runAddrUpdateEventLoop listen network change and restart udp and websocket listener
|
||||||
func (c *PeerPacketConn) runAddrUpdateEventLoop() {
|
func (c *PeerPacketConn) runAddrUpdateEventLoop() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
Reference in New Issue
Block a user