diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-10 18:19:11 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-10 18:19:11 +0100 |
commit | 75e6d810edd3026b60fb3ca7b759236e555c2d0d (patch) | |
tree | e9f71167b2d60f7477dbba075abc0096304f1fbb /device/peer.go | |
parent | 747f5440bc18492a63eb91cba7db72b16c96176d (diff) |
device: use container/list instead of open coding it
This linked list implementation is awful, but maybe Go 2 will help
eventually, and at least we're not open coding the hlist any more.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/peer.go')
-rw-r--r-- | device/peer.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/device/peer.go b/device/peer.go index a3b428a..499888d 100644 --- a/device/peer.go +++ b/device/peer.go @@ -6,6 +6,7 @@ package device import ( + "container/list" "encoding/base64" "errors" "fmt" @@ -17,15 +18,13 @@ import ( ) type Peer struct { - isRunning AtomicBool - sync.RWMutex // Mostly protects endpoint, but is generally taken whenever we modify peer - keypairs Keypairs - handshake Handshake - device *Device - endpoint conn.Endpoint - persistentKeepaliveInterval uint32 // accessed atomically - firstTrieEntry *trieEntry - stopping sync.WaitGroup // routines pending stop + isRunning AtomicBool + sync.RWMutex // Mostly protects endpoint, but is generally taken whenever we modify peer + keypairs Keypairs + handshake Handshake + device *Device + endpoint conn.Endpoint + stopping sync.WaitGroup // routines pending stop // These fields are accessed with atomic operations, which must be // 64-bit aligned even on 32-bit platforms. Go guarantees that an @@ -61,7 +60,9 @@ type Peer struct { inbound *autodrainingInboundQueue // sequential ordering of tun writing } - cookieGenerator CookieGenerator + cookieGenerator CookieGenerator + trieEntries list.List + persistentKeepaliveInterval uint32 // accessed atomically } func (device *Device) NewPeer(pk NoisePublicKey) (*Peer, error) { |