From 8c52ccadf9fe4aeae0e2f29c81905f9efb7e2716 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 1 Sep 2019 14:07:00 -0500 Subject: [PATCH] make dial fail if a session to the same node already exists, fixes race between simultaneous connections to a node's 200 address and one of its 300 addresses, should also fix races between a search and an accepted listen --- src/yggdrasil/search.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/yggdrasil/search.go b/src/yggdrasil/search.go index c128175b..322131ed 100644 --- a/src/yggdrasil/search.go +++ b/src/yggdrasil/search.go @@ -204,6 +204,11 @@ func (sinfo *searchInfo) checkDHTRes(res *dhtRes) bool { if !isIn { panic("This should never happen") } + } else { + sinfo.callback(nil, errors.New("session already exists")) + // Cleanup + delete(sinfo.searches.searches, res.Dest) + return true } // FIXME (!) replay attacks could mess with coords? Give it a handle (tstamp)? sess.coords = res.Coords