aboutsummaryrefslogtreecommitdiffstats
path: root/src/receive.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2018-02-01 11:20:36 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2018-02-01 11:20:36 +0100
commit1e42b1402261d15b87b1b5871f7bc51342b46e34 (patch)
treeaef0aef2eadf6ae7142486069405f45b84d59b58 /src/receive.go
parentAdded binary to .gitignore (diff)
parentAdded initial version of peer teardown (diff)
downloadwireguard-go-1e42b1402261d15b87b1b5871f7bc51342b46e34.tar.xz
wireguard-go-1e42b1402261d15b87b1b5871f7bc51342b46e34.zip
Merge branch 'timer-teardown' of git.zx2c4.com:wireguard-go into timer-teardown
Diffstat (limited to '')
-rw-r--r--src/receive.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/receive.go b/src/receive.go
index 0b87a3c..5ad7c4b 100644
--- a/src/receive.go
+++ b/src/receive.go
@@ -123,7 +123,7 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind Bind) {
case ipv6.Version:
size, endpoint, err = bind.ReceiveIPv6(buffer[:])
default:
- return
+ panic("invalid IP version")
}
if err != nil {
@@ -184,9 +184,11 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind Bind) {
// add to decryption queues
- device.addToDecryptionQueue(device.queue.decryption, elem)
- device.addToInboundQueue(peer.queue.inbound, elem)
- buffer = device.GetMessageBuffer()
+ if peer.isRunning.Get() {
+ device.addToDecryptionQueue(device.queue.decryption, elem)
+ device.addToInboundQueue(peer.queue.inbound, elem)
+ buffer = device.GetMessageBuffer()
+ }
continue
@@ -308,13 +310,20 @@ func (device *Device) RoutineHandshake() {
return
}
- // lookup peer and consume response
+ // lookup peer from index
entry := device.indices.Lookup(reply.Receiver)
+
if entry.peer == nil {
continue
}
- entry.peer.mac.ConsumeReply(&reply)
+
+ // consume reply
+
+ if peer := entry.peer; peer.isRunning.Get() {
+ peer.mac.ConsumeReply(&reply)
+ }
+
continue
case MessageInitiationType, MessageResponseType: