close connection when failing to decrypt packets
Since we may never recover from that if nonces got out of sync. Closes #274.
This commit is contained in:
1 parent
f792bf7ef8
commit
7cfb79cfc1
3 files changed
+8
-3
No files matched your search
+1
-1
@@ -286,7 +286,7 @@ func (nd *NaClDecryptor) ReceiveNonce(msg []byte) {
|
||||
func (nd *NaClDecryptor) IterateFrames(fun FrameConsumer, packet *UDPPacket) error {
|
||||
buf, err := nd.decrypt(packet.Packet)
|
||||
if err != nil {
|
||||
return PacketDecodingError{Desc: fmt.Sprint("decryption failed; ", err)}
|
||||
return PacketDecodingError{Fatal: true, Desc: fmt.Sprint("decryption failed; ", err)}
|
||||
}
|
||||
packet.Packet = buf
|
||||
return nd.NonDecryptor.IterateFrames(fun, packet)
|
||||
|
||||
+5
-1
@@ -209,7 +209,11 @@ func (router *Router) udpReader(conn *net.UDPConn, po PacketSink) {
|
||||
}
|
||||
err = relayConn.Decryptor.IterateFrames(handleUDPPacket, udpPacket)
|
||||
if pde, ok := err.(PacketDecodingError); ok {
|
||||
relayConn.log(pde.Error())
|
||||
if pde.Fatal {
|
||||
relayConn.CheckFatal(pde)
|
||||
} else {
|
||||
relayConn.log(pde.Error())
|
||||
}
|
||||
} else {
|
||||
checkWarn(err)
|
||||
}
|
||||
|
||||
+2
-1
@@ -114,7 +114,8 @@ type NameCollisionError struct {
|
||||
}
|
||||
|
||||
type PacketDecodingError struct {
|
||||
Desc string
|
||||
Fatal bool
|
||||
Desc string
|
||||
}
|
||||
|
||||
type LocalAddress struct {
|
||||
|
||||
Reference in new issue
Block a user