diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-07-01 23:29:22 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-07-01 23:29:22 +0200 |
commit | 1e620427bd01b1e897c57752359f7dbb28e34bff (patch) | |
tree | f525ee38fec7826b07060271dcc06601f992612d /src/peer.go | |
parent | a4cc0a30faa64c2c293c589d98e4ba7390e56fda (diff) |
Handshake negotiation functioning
Diffstat (limited to 'src/peer.go')
-rw-r--r-- | src/peer.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/peer.go b/src/peer.go index e885cee..1c40598 100644 --- a/src/peer.go +++ b/src/peer.go @@ -37,6 +37,7 @@ type Peer struct { queue struct { nonce chan []byte // nonce / pre-handshake queue outbound chan *QueueOutboundElement // sequential ordering of work + inbound chan *QueueInboundElement // sequential ordering of work } mac MacStatePeer } @@ -47,11 +48,10 @@ func (device *Device) NewPeer(pk NoisePublicKey) *Peer { peer := new(Peer) peer.mutex.Lock() defer peer.mutex.Unlock() - peer.device = device + peer.mac.Init(pk) - peer.queue.outbound = make(chan *QueueOutboundElement, QueueOutboundSize) - peer.queue.nonce = make(chan []byte, QueueOutboundSize) - peer.timer.sendKeepalive = StoppedTimer() + peer.device = device + peer.timer.sendKeepalive = stoppedTimer() // assign id for debugging @@ -76,6 +76,12 @@ func (device *Device) NewPeer(pk NoisePublicKey) *Peer { handshake.precomputedStaticStatic = device.privateKey.sharedSecret(handshake.remoteStatic) handshake.mutex.Unlock() + // prepare queuing + + peer.queue.nonce = make(chan []byte, QueueOutboundSize) + peer.queue.inbound = make(chan *QueueInboundElement, QueueInboundSize) + peer.queue.outbound = make(chan *QueueOutboundElement, QueueOutboundSize) + // prepare signaling peer.signal.stop = make(chan struct{}) @@ -89,6 +95,7 @@ func (device *Device) NewPeer(pk NoisePublicKey) *Peer { go peer.RoutineNonce() go peer.RoutineHandshakeInitiator() go peer.RoutineSequentialSender() + go peer.RoutineSequentialReceiver() return peer } |