summaryrefslogtreecommitdiffhomepage
path: root/peer.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2018-05-05 04:15:07 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2018-05-05 04:15:07 +0200
commit7a83f2565a13624d8cb9ca6adf1aced721777a9c (patch)
tree6b26f71c245b7ac3f1baba9d56dfd636c5b79d4f /peer.go
parent4d9f3a2f535b8ddefff5ed70c8d191106c3030fa (diff)
Removed old signals
Diffstat (limited to 'peer.go')
-rw-r--r--peer.go43
1 files changed, 16 insertions, 27 deletions
diff --git a/peer.go b/peer.go
index d43f020..0b947fd 100644
--- a/peer.go
+++ b/peer.go
@@ -15,7 +15,7 @@ import (
const (
PeerRoutineNumber = 4
- EventInterval = time.Millisecond
+ EventInterval = 10 * time.Millisecond
)
type Peer struct {
@@ -46,18 +46,14 @@ type Peer struct {
dataReceived *Event
anyAuthenticatedPacketReceived *Event
anyAuthenticatedPacketTraversal *Event
- handshakeComplete *Event
+ handshakeCompleted *Event
handshakePushDeadline *Event
+ handshakeBegin *Event
ephemeralKeyCreated *Event
+ newKeyPair *Event
}
signal struct {
- newKeyPair Signal // size 1, new key pair was generated
- handshakeCompleted Signal // size 1, handshake completed
- handshakeBegin Signal // size 1, begin new handshake begin
- messageSend Signal // size 1, message was send to peer
- messageReceived Signal // size 1, authenticated message recv
-
flushNonceQueue chan struct{} // size 0, empty queued packets
}
@@ -115,6 +111,18 @@ func (device *Device) NewPeer(pk NoisePublicKey) (*Peer, error) {
peer.device = device
peer.isRunning.Set(false)
+ // events
+
+ peer.event.dataSent = newEvent(EventInterval)
+ peer.event.dataReceived = newEvent(EventInterval)
+ peer.event.anyAuthenticatedPacketReceived = newEvent(EventInterval)
+ peer.event.anyAuthenticatedPacketTraversal = newEvent(EventInterval)
+ peer.event.handshakeCompleted = newEvent(EventInterval)
+ peer.event.handshakePushDeadline = newEvent(EventInterval)
+ peer.event.handshakeBegin = newEvent(EventInterval)
+ peer.event.ephemeralKeyCreated = newEvent(EventInterval)
+ peer.event.newKeyPair = newEvent(EventInterval)
+
// map public key
_, ok := device.peers.keyMap[pk]
@@ -202,22 +210,8 @@ func (peer *Peer) Start() {
peer.routines.starting.Wait()
peer.routines.stopping.Wait()
- // events
-
- peer.event.dataSent = newEvent(EventInterval)
- peer.event.dataReceived = newEvent(EventInterval)
- peer.event.anyAuthenticatedPacketReceived = newEvent(EventInterval)
- peer.event.anyAuthenticatedPacketTraversal = newEvent(EventInterval)
- peer.event.handshakeComplete = newEvent(EventInterval)
- peer.event.handshakePushDeadline = newEvent(EventInterval)
- peer.event.ephemeralKeyCreated = newEvent(EventInterval)
-
// prepare queues and signals
- peer.signal.newKeyPair = NewSignal()
- peer.signal.handshakeBegin = NewSignal()
- peer.signal.handshakeCompleted = NewSignal()
-
peer.signal.flushNonceQueue = make(chan struct{})
peer.queue.nonce = make(chan *QueueOutboundElement, QueueOutboundSize)
@@ -269,12 +263,7 @@ func (peer *Peer) Stop() {
// close signals
- peer.signal.newKeyPair.Close()
- peer.signal.handshakeBegin.Close()
- peer.signal.handshakeCompleted.Close()
-
close(peer.signal.flushNonceQueue)
-
peer.signal.flushNonceQueue = nil
// clear key pairs