From c16dce9f6014f6c6379baee8b58a7bff5bcab71d Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 3 Nov 2016 17:30:16 +0100 Subject: [PATCH 1/2] Make it possible to request stop of message loop Add a `RequestStopMessageLoop()` method to `Ricochet` to be able to stop handling new connections. Right now, ProcessMessages is an infinite loop. --- ricochet.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ricochet.go b/ricochet.go index b2036ab..ca78446 100644 --- a/ricochet.go +++ b/ricochet.go @@ -93,10 +93,19 @@ func (r *Ricochet) processNewConnection(conn net.Conn, service RicochetService) func (r *Ricochet) ProcessMessages(service RicochetService) { for { oc := <-r.newconns + if oc == nil { + return + } go r.processConnection(oc, service) } } +// Request that the ProcessMessages loop is stopped after handling all currently +// queued new connections. +func (r *Ricochet) RequestStopMessageLoop() { + r.newconns <- nil +} + // ProcessConnection starts a blocking process loop which continually waits for // new messages to arrive from the connection and uses the given RicochetService // to process them. From 5e3e873a166b9aab4943d6e482d9244ff2551b85 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 3 Nov 2016 17:35:10 +0100 Subject: [PATCH 2/2] networkresolver: fix gofmt output --- utils/networkresolver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/networkresolver.go b/utils/networkresolver.go index 9395773..e2873d8 100644 --- a/utils/networkresolver.go +++ b/utils/networkresolver.go @@ -40,7 +40,7 @@ func (nr *NetworkResolver) Resolve(hostname string) (net.Conn, string, error) { torDialer, err := proxy.SOCKS5("tcp", "127.0.0.1:9050", nil, proxy.Direct) if err != nil { - return nil,"", err + return nil, "", err } conn, err := torDialer.Dial("tcp", resolvedHostname+".onion:9878")