summaryrefslogtreecommitdiffhomepage
path: root/receive.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2018-05-05 02:20:52 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2018-05-05 02:20:52 +0200
commit6db41d5a269c79bd04b18dbfa171cc241a6cdcc9 (patch)
tree7cfd9a8461b5c66dd971971e3706ada4c8b0484a /receive.go
parent168ef61a638e4875b260edbc51551bae0dc34ac3 (diff)
Initial version of migration to new event model
- Begin move away from global timer state. - Made logging format more consistent
Diffstat (limited to 'receive.go')
-rw-r--r--receive.go25
1 files changed, 14 insertions, 11 deletions
diff --git a/receive.go b/receive.go
index 7d35497..e779012 100644
--- a/receive.go
+++ b/receive.go
@@ -207,6 +207,9 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind Bind) {
case MessageCookieReplyType:
okay = len(packet) == MessageCookieReplySize
+
+ default:
+ logDebug.Println("Received message with unknown type")
}
if okay {
@@ -457,7 +460,7 @@ func (device *Device) RoutineHandshake() {
peer.endpoint = elem.endpoint
peer.mutex.Unlock()
- logDebug.Println(peer.String() + ": Received handshake initiation")
+ logDebug.Println(peer, ": Received handshake initiation")
// create response
@@ -470,7 +473,7 @@ func (device *Device) RoutineHandshake() {
peer.TimerEphemeralKeyCreated()
peer.NewKeyPair()
- logDebug.Println(peer.String(), "Creating handshake response")
+ logDebug.Println(peer, ": Creating handshake response")
writer := bytes.NewBuffer(temp[:0])
binary.Write(writer, binary.LittleEndian, response)
@@ -483,7 +486,7 @@ func (device *Device) RoutineHandshake() {
if err == nil {
peer.TimerAnyAuthenticatedPacketTraversal()
} else {
- logError.Println(peer.String(), "Failed to send handshake response", err)
+ logError.Println(peer, ": Failed to send handshake response", err)
}
case MessageResponseType:
@@ -515,7 +518,7 @@ func (device *Device) RoutineHandshake() {
peer.endpoint = elem.endpoint
peer.mutex.Unlock()
- logDebug.Println(peer.String() + ": Received handshake response")
+ logDebug.Println(peer, ": Received handshake response")
peer.TimerEphemeralKeyCreated()
@@ -542,10 +545,10 @@ func (peer *Peer) RoutineSequentialReceiver() {
defer func() {
peer.routines.stopping.Done()
- logDebug.Println(peer.String() + ": Routine: sequential receiver - stopped")
+ logDebug.Println(peer, ": Routine: sequential receiver - stopped")
}()
- logDebug.Println(peer.String() + ": Routine: sequential receiver - started")
+ logDebug.Println(peer, ": Routine: sequential receiver - started")
peer.routines.starting.Done()
@@ -604,7 +607,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
// check for keep-alive
if len(elem.packet) == 0 {
- logDebug.Println("Received keep-alive from", peer.String())
+ logDebug.Println(peer, ": Received keep-alive")
continue
}
peer.TimerDataReceived()
@@ -634,7 +637,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
if device.routing.table.LookupIPv4(src) != peer {
logInfo.Println(
"IPv4 packet with disallowed source address from",
- peer.String(),
+ peer,
)
continue
}
@@ -661,14 +664,14 @@ func (peer *Peer) RoutineSequentialReceiver() {
src := elem.packet[IPv6offsetSrc : IPv6offsetSrc+net.IPv6len]
if device.routing.table.LookupIPv6(src) != peer {
logInfo.Println(
- "IPv6 packet with disallowed source address from",
- peer.String(),
+ peer,
+ "sent packet with disallowed IPv6 source",
)
continue
}
default:
- logInfo.Println("Packet with invalid IP version from", peer.String())
+ logInfo.Println("Packet with invalid IP version from", peer)
continue
}