mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-10-16 13:41:24 +08:00
Clean more
This commit is contained in:
14
device.go
14
device.go
@@ -225,15 +225,15 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) error {
|
||||
|
||||
for key, peer := range device.peers.keyMap {
|
||||
|
||||
hs := &peer.handshake
|
||||
handshake := &peer.handshake
|
||||
|
||||
if rmKey {
|
||||
hs.precomputedStaticStatic = [NoisePublicKeySize]byte{}
|
||||
handshake.precomputedStaticStatic = [NoisePublicKeySize]byte{}
|
||||
} else {
|
||||
hs.precomputedStaticStatic = device.staticIdentity.privateKey.sharedSecret(hs.remoteStatic)
|
||||
handshake.precomputedStaticStatic = device.staticIdentity.privateKey.sharedSecret(handshake.remoteStatic)
|
||||
}
|
||||
|
||||
if isZero(hs.precomputedStaticStatic[:]) {
|
||||
if isZero(handshake.precomputedStaticStatic[:]) {
|
||||
unsafeRemovePeer(device, peer, key)
|
||||
}
|
||||
}
|
||||
@@ -267,18 +267,12 @@ func NewDevice(tun TUNDevice, logger *Logger) *Device {
|
||||
|
||||
device.peers.keyMap = make(map[NoisePublicKey]*Peer)
|
||||
|
||||
// initialize rate limiter
|
||||
|
||||
device.rate.limiter.Init()
|
||||
device.rate.underLoadUntil.Store(time.Time{})
|
||||
|
||||
// initialize staticIdentity & crypt-key routine
|
||||
|
||||
device.indexTable.Init()
|
||||
device.allowedips.Reset()
|
||||
|
||||
// setup buffer pool
|
||||
|
||||
device.pool.messageBuffers = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return new([MaxMessageSize]byte)
|
||||
|
Reference in New Issue
Block a user