From f3c299acf99d7ca14429480b09b359a3a3dae0ec Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Mon, 23 Jan 2017 09:11:19 -0800 Subject: [PATCH] lib/tunnel: make each conn have its own server --- lib/tunnel/httpproxy.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/tunnel/httpproxy.go b/lib/tunnel/httpproxy.go index 9aa8a83..8c2a58c 100644 --- a/lib/tunnel/httpproxy.go +++ b/lib/tunnel/httpproxy.go @@ -62,12 +62,9 @@ func (p *HTTPProxy) Proxy(remote net.Conn, msg *proto.ControlMessage) { localAddr = p.LocalAddr } - if p.hs == nil { + if p.rp == nil { su, _ := url.Parse(fmt.Sprintf("http://%s", p.LocalAddr)) p.rp = httputil.NewSingleHostReverseProxy(su) - p.hs = &http.Server{ - Handler: p.rp, - } } log.Debug("Dialing local server %q", localAddr) @@ -76,7 +73,11 @@ func (p *HTTPProxy) Proxy(remote net.Conn, msg *proto.ControlMessage) { conn: remote, } - err := p.hs.Serve(sl) + hs := &http.Server{ + Handler: p.rp, + } + + err := hs.Serve(sl) if err != nil { log.Error("Dialing local server %q failed: %s", localAddr, err) p.sendError(remote)