gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 4ac508f037119e42cc2b4274cfd4bb03fe69bf44
parent 9f2a2abe42a6211df6970ba7625d245298778a38
Author: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>
Date:   Sun, 15 May 2022 10:10:55 +0100

[chore] Update LE server to use copy of main http.Server{} to maintain server timeouts etc (#571)

* update LE server to use copy of main HTTP server to maintain server timeouts etc

Signed-off-by: kim <grufwub@gmail.com>

* shutup linter

Signed-off-by: kim <grufwub@gmail.com>
Diffstat:
Minternal/router/router.go | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/internal/router/router.go b/internal/router/router.go @@ -91,15 +91,19 @@ func (r *router) Start() { http.Redirect(rw, r, target, http.StatusTemporaryRedirect) }) - // Start the LetsEncrypt autocert manager HTTP server. go func() { - addr := fmt.Sprintf("%s:%d", + // Take our own copy of HTTP server + // with updated autocert manager endpoint + srv := (*r.srv) //nolint + srv.Handler = r.certManager.HTTPHandler(redirect) + srv.Addr = fmt.Sprintf("%s:%d", viper.GetString(keys.BindAddress), viper.GetInt(keys.LetsEncryptPort), ) - logrus.Infof("letsencrypt listening on %s", addr) - if err := http.ListenAndServe(addr, r.certManager.HTTPHandler(redirect)); err != nil && + // Start the LetsEncrypt autocert manager HTTP server. + logrus.Infof("letsencrypt listening on %s", srv.Addr) + if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { logrus.Fatalf("letsencrypt: listen: %s", err) }