diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-12-01 23:37:26 +0100 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-12-01 23:37:26 +0100 |
commit | eaca1ee1f79422a501394415fd4ae8f227a134af (patch) | |
tree | 1fbfad20b2e9a6b68d5ccd928ed6678596de76b9 /src/receive.go | |
parent | cb09125dc4c64360697af700ba71331d91e9edcd (diff) |
More consistent use of signal struct
Diffstat (limited to 'src/receive.go')
-rw-r--r-- | src/receive.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/receive.go b/src/receive.go index fd1993e..f650cc9 100644 --- a/src/receive.go +++ b/src/receive.go @@ -93,6 +93,11 @@ func (device *Device) addToHandshakeQueue( } } +/* Receives incoming datagrams for the device + * + * Every time the bind is updated a new routine is started for + * IPv4 and IPv6 (separately) + */ func (device *Device) RoutineReceiveIncoming(IP int, bind Bind) { logDebug := device.log.Debug @@ -182,6 +187,7 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind Bind) { device.addToDecryptionQueue(device.queue.decryption, elem) device.addToInboundQueue(peer.queue.inbound, elem) buffer = device.GetMessageBuffer() + continue // otherwise it is a fixed size & handshake related packet @@ -220,7 +226,7 @@ func (device *Device) RoutineDecryption() { for { select { - case <-device.signal.stop: + case <-device.signal.stop.Wait(): logDebug.Println("Routine, decryption worker, stopped") return @@ -256,7 +262,7 @@ func (device *Device) RoutineDecryption() { } } -/* Handles incomming packets related to handshake +/* Handles incoming packets related to handshake */ func (device *Device) RoutineHandshake() { @@ -271,7 +277,7 @@ func (device *Device) RoutineHandshake() { for { select { case elem = <-device.queue.handshake: - case <-device.signal.stop: + case <-device.signal.stop.Wait(): return } @@ -356,7 +362,7 @@ func (device *Device) RoutineHandshake() { continue } - // handle handshake initation/response content + // handle handshake initiation/response content switch elem.msgType { case MessageInitiationType: @@ -376,7 +382,7 @@ func (device *Device) RoutineHandshake() { peer := device.ConsumeMessageInitiation(&msg) if peer == nil { logInfo.Println( - "Recieved invalid initiation message from", + "Received invalid initiation message from", elem.endpoint.DstToString(), ) continue @@ -449,7 +455,7 @@ func (device *Device) RoutineHandshake() { peer.endpoint = elem.endpoint peer.mutex.Unlock() - logDebug.Println("Received handshake initation from", peer) + logDebug.Println("Received handshake initiation from", peer) peer.TimerEphemeralKeyCreated() @@ -556,7 +562,7 @@ func (peer *Peer) RoutineSequentialReceiver() { src := elem.packet[IPv4offsetSrc : IPv4offsetSrc+net.IPv4len] if device.routingTable.LookupIPv4(src) != peer { logInfo.Println( - "IPv4 packet with unallowed source address from", + "IPv4 packet with disallowed source address from", peer.String(), ) continue @@ -584,7 +590,7 @@ func (peer *Peer) RoutineSequentialReceiver() { src := elem.packet[IPv6offsetSrc : IPv6offsetSrc+net.IPv6len] if device.routingTable.LookupIPv6(src) != peer { logInfo.Println( - "IPv6 packet with unallowed source address from", + "IPv6 packet with disallowed source address from", peer.String(), ) continue |