tFail if we did not publish a descriptor within 90 seconds - tordam - A library for peer discovery inside the Tor network (HTM) git clone https://git.parazyd.org/tordam (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 53f4dc327a13a5dc72ab93d34717dbb6d7a3d396 (DIR) parent a1b6f917447996d575c6bf314144873c626f7557 (HTM) Author: parazyd <parazyd@dyne.org> Date: Fri, 8 Dec 2017 18:05:27 +0100 Fail if we did not publish a descriptor within 90 seconds Diffstat: M cmd/dam-client/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+), 0 deletions(-) --- (DIR) diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go t@@ -9,6 +9,7 @@ import ( "log" "os" "os/exec" + "time" "github.com/parazyd/tor-dam/pkg/lib" ) t@@ -48,6 +49,18 @@ func main() { scanner := bufio.NewScanner(stdout) ok := false + go func() { + // If we do not manage to publish our descriptor, we will exit. + t1 := time.Now().Unix() + for !(ok) { + t2 := time.Now().Unix() + if t2-t1 > 90 { + cmd.Process.Kill() + log.Fatalln("Too much time passed. Exiting.") + } + time.Sleep(1000 * time.Millisecond) + } + }() for !(ok) { scanner.Scan() status := scanner.Text()