diff options
Diffstat (limited to 'device/keypair.go')
-rw-r--r-- | device/keypair.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/device/keypair.go b/device/keypair.go index 9c78fa9..d70c7f4 100644 --- a/device/keypair.go +++ b/device/keypair.go @@ -8,7 +8,9 @@ package device import ( "crypto/cipher" "sync" + "sync/atomic" "time" + "unsafe" "golang.zx2c4.com/wireguard/replay" ) @@ -38,6 +40,14 @@ type Keypairs struct { next *Keypair } +func (kp *Keypairs) storeNext(next *Keypair) { + atomic.StorePointer((*unsafe.Pointer)((unsafe.Pointer)(&kp.next)), (unsafe.Pointer)(next)) +} + +func (kp *Keypairs) loadNext() *Keypair { + return (*Keypair)(atomic.LoadPointer((*unsafe.Pointer)((unsafe.Pointer)(&kp.next)))) +} + func (kp *Keypairs) Current() *Keypair { kp.RLock() defer kp.RUnlock() |