From e87cc29b362193439977e3096e785a496d840b3d Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 29 Jul 2017 11:56:38 -0700 Subject: [PATCH] brontide: add additional detail to handshake version error message This commit adds some additional detail to the error message encountered when the first byte of an act is an invalid handshake version byte. This commit is meant to aide in tracking down a re-occurring bug that has been encountered by early testers of the software. --- brontide/noise.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/brontide/noise.go b/brontide/noise.go index 2ab935bf..8cc21066 100644 --- a/brontide/noise.go +++ b/brontide/noise.go @@ -427,8 +427,9 @@ func (b *Machine) RecvActOne(actOne [ActOneSize]byte) error { // If the handshake version is unknown, then the handshake fails // immediately. if actOne[0] != HandshakeVersion { - return fmt.Errorf("Invalid handshake version: %v, only %v is "+ - "valid", actOne[0], HandshakeVersion) + return fmt.Errorf("Act One: invalid handshake version: %v, "+ + "only %v is valid, msg=%x", actOne[0], HandshakeVersion, + actOne[:]) } copy(e[:], actOne[1:34]) @@ -498,8 +499,9 @@ func (b *Machine) RecvActTwo(actTwo [ActTwoSize]byte) error { // If the handshake version is unknown, then the handshake fails // immediately. if actTwo[0] != HandshakeVersion { - return fmt.Errorf("Invalid handshake version: %v, only %v is "+ - "valid", actTwo[0], HandshakeVersion) + return fmt.Errorf("Act Two: invalid handshake version: %v, "+ + "only %v is valid, msg=%x", actTwo[0], HandshakeVersion, + actTwo[:]) } copy(e[:], actTwo[1:34]) @@ -563,8 +565,9 @@ func (b *Machine) RecvActThree(actThree [ActThreeSize]byte) error { // If the handshake version is unknown, then the handshake fails // immediately. if actThree[0] != HandshakeVersion { - return fmt.Errorf("Invalid handshake version: %v, only %v is "+ - "valid", actThree[0], HandshakeVersion) + return fmt.Errorf("Act Three: invalid handshake version: %v, "+ + "only %v is valid, msg=%x", actThree[0], HandshakeVersion, + actThree[:]) } // TODO(roasbeef): print out entire version each time, also print out