From 6629d906683487ad4bb497120a15a8a54f9a1cda Mon Sep 17 00:00:00 2001 From: Jon Penn Date: Sat, 28 Aug 2021 16:18:35 -0500 Subject: [PATCH 1/2] allow alternate ACME urls --- main.go | 5 +++++ vars.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/main.go b/main.go index 62de27b..6893d08 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" + "golang.org/x/crypto/acme" "golang.org/x/crypto/acme/autocert" ) @@ -13,6 +14,10 @@ func main() { e.HideBanner = true e.AutoTLSManager.HostPolicy = autocert.HostWhitelist(getAvailableHosts()...) e.AutoTLSManager.Cache = autocert.DirCache(*flagAutocertCacheDir) + e.AutoTLSManager.Client = &acme.Client{ + DirectoryURL: *flagACMEDirectory, + UserAgent: "https://github.com/alash3al/httpsify", + } e.Use(middleware.HTTPSRedirect()) e.Use(middleware.Logger()) diff --git a/vars.go b/vars.go index c9d1e4f..70406e4 100644 --- a/vars.go +++ b/vars.go @@ -6,6 +6,7 @@ import ( "sync/atomic" "github.com/mitchellh/go-homedir" + "golang.org/x/crypto/acme/autocert" ) var ( @@ -18,5 +19,6 @@ var ( flagHTTPAddr = flag.String("http", ":80", "the port to listen for http requests on, it is recommended to leave it as is") flagAutocertCacheDir = flag.String("certs", path.Join(homeDir, ".httpsify/certs"), "the certs directory") flagHostsFile = flag.String("hosts", path.Join(homeDir, ".httpsify/hosts.json"), "the file containing hosts mappings to upstreams") + flagACMEDirectory = flag.String("acme-directory", autocert.DefaultACMEDirectory, "the server to request certificates from") flagSendXSecuredBy = flag.Bool("x-secured-by", true, "whether to enable x-secured-by header or not") ) From 160011c5ce0e02c8772056940a8868bf65c05795 Mon Sep 17 00:00:00 2001 From: Jon Penn Date: Sat, 28 Aug 2021 19:15:21 -0500 Subject: [PATCH 2/2] remove unnecessary select --- hosts.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hosts.go b/hosts.go index 2dc72b8..ad82dd2 100644 --- a/hosts.go +++ b/hosts.go @@ -76,10 +76,8 @@ func watchHostsChanges(filename string, fn func()) error { watcher.Add(filename) for { - select { - case <-watcher.Events: - fn() - } + <-watcher.Events + fn() } }