tAnnounce to known directories concurrently. - tordam - A library for peer discovery inside the Tor network HTML git clone https://git.parazyd.org/tordam DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit a21e7672224c07101f34819e76a97d9944764d09 DIR parent c0a9715772f824767c5ae8803bfdb0a1709a93f6 HTML Author: parazyd <parazyd@dyne.org> Date: Sat, 9 Dec 2017 15:54:25 +0100 Announce to known directories concurrently. Diffstat: M cmd/dam-client/main.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) --- DIR diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go t@@ -10,6 +10,7 @@ import ( "log" "os" "os/exec" + "sync" "time" "github.com/parazyd/tor-dam/pkg/lib" t@@ -166,13 +167,21 @@ func main() { var ann = 0 // Track of how many successful authentications dirs := []string{"qvhgzxjkdchj2jl5.onion", "localhost"} + + var wg sync.WaitGroup for _, i := range dirs { - valid, err := announce(i, nodevals, key) - lib.CheckError(err) - if valid { - ann++ - } + wg.Add(1) + go func(x string) { + valid, err := announce(x, nodevals, key) + lib.CheckError(err) + if valid { + ann++ + } + wg.Done() + }(i) } + wg.Wait() + if ann > 0 { log.Printf("Successfully authenticated with %d nodes.\n", ann) } else {