tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit 9b22c43c76f6b74a58f06bdc6544977e6d77e582
parent 7a697d4ef254930b0eb9f9c7da12af1415ede4fd
Author: parazyd <parazyd@dyne.org>
Date:   Thu,  7 Dec 2017 19:19:23 +0100

ListenAndServe in a goroutine

Diffstat:
Mgo/ddir/ddir.go | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/go/ddir/ddir.go b/go/ddir/ddir.go @@ -6,6 +6,7 @@ import ( "encoding/json" "log" "net/http" + "sync" "../lib" ) @@ -40,7 +41,13 @@ func handlePost(rw http.ResponseWriter, request *http.Request) { } func main() { + var wg sync.WaitGroup + http.HandleFunc("/announce", handlePost) - http.ListenAndServe(ListenAddress, nil) + + wg.Add(1) + go http.ListenAndServe(ListenAddress, nil) log.Println("Listening on", ListenAddress) + + wg.Wait() }