From 7b42da1bf300433997e9092621cb710ae3e05ab3 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Thu, 11 Jan 2018 02:19:46 +0100 Subject: [PATCH] fix; handling http.proxy stop gracefully --- modules/http_proxy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/http_proxy.go b/modules/http_proxy.go index 3e38811b..e8e16dfd 100644 --- a/modules/http_proxy.go +++ b/modules/http_proxy.go @@ -1,9 +1,11 @@ package modules import ( + "context" "fmt" "net/http" "strings" + "time" "github.com/elazarl/goproxy" @@ -191,7 +193,9 @@ func (p *HttpProxy) Start() error { func (p *HttpProxy) Stop() error { if p.Running() == true { p.SetRunning(false) - p.server.Shutdown(nil) + ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + defer cancel() + p.server.Shutdown(ctx) if p.redirection != nil { log.Debug("Disabling redirection %s", p.redirection.String()) if err := p.Session.Firewall.EnableRedirection(p.redirection, false); err != nil {