From 18a6f09cae7f280a2a9f506feceaad9e6ef27ef3 Mon Sep 17 00:00:00 2001 From: Jens Zeilund Date: Sun, 20 May 2018 19:41:19 +0200 Subject: [PATCH] Clean up and remove debug code --- aproxy.go | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/aproxy.go b/aproxy.go index 0387ef6..bdbc9f2 100644 --- a/aproxy.go +++ b/aproxy.go @@ -1,6 +1,7 @@ package main import ( + "crypto/tls" "flag" "fmt" "keybase/sketchground/aproxygo/aproxy" @@ -10,7 +11,6 @@ import ( "net/url" "strings" "sync" - "time" "golang.org/x/crypto/acme/autocert" ) @@ -114,15 +114,13 @@ func main() { wg := sync.WaitGroup{} wg.Add(1) go func() { - /* - log.Println("Starting reverse proxy for ssl connections") - s := &http.Server{ - Addr: ":https", - TLSConfig: &tls.Config{GetCertificate: mgr.GetCertificate}, - Handler: NewP(true, tracker), - } - log.Fatal(s.ListenAndServeTLS("", "")) - */ + log.Println("Starting reverse proxy for ssl connections") + s := &http.Server{ + Addr: ":https", + TLSConfig: &tls.Config{GetCertificate: mgr.GetCertificate}, + Handler: NewP(true, tracker), + } + log.Fatal(s.ListenAndServeTLS("", "")) wg.Done() }() wg.Add(1) @@ -133,14 +131,7 @@ func main() { }() wg.Wait() - // Shut down track channel... - - //TODO: Process left of logs for service. Then shut down. - fmt.Println("SLeeping before shutdown") - time.Sleep(10 * time.Second) - fmt.Println("going down") tracker.Shutdown() - fmt.Println("went down") } func NewP(secure bool, t *aproxy.Tracker) *P { @@ -157,13 +148,11 @@ type P struct { func (p *P) ServeHTTP(rw http.ResponseWriter, req *http.Request) { log.Printf("Receiving quest on path: %v", req.URL) - /* - if !p.secure { // Redirect always if not secure. - u := fmt.Sprintf("https://%v%v", req.Host, req.URL.Path) - http.Redirect(rw, req, u, http.StatusFound) - return - } - */ + if !p.secure { // Redirect always if not secure. + u := fmt.Sprintf("https://%v%v", req.Host, req.URL.Path) + http.Redirect(rw, req, u, http.StatusFound) + return + } // TODO: Investigate if this should be guarded for concurrent access? p.t.Track(req.Context(), req) -- 2.30.1