From ce12384c157d9bdf8c3b4dbe91d797e86cb94375 Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Sat, 12 Aug 2023 15:58:41 +0100 Subject: [PATCH] Log incoming requests --- servers/api/api.go | 1 + servers/https.go | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/servers/api/api.go b/servers/api/api.go index a4c6064..87b7b36 100644 --- a/servers/api/api.go +++ b/servers/api/api.go @@ -62,6 +62,7 @@ func domainManage(verify mjwt.Verifier, domains utils.DomainProvider) httprouter // add domain with active state domains.Put(params.ByName("domain"), req.Method == http.MethodPut) domains.Compile() + rw.WriteHeader(http.StatusAccepted) }) } diff --git a/servers/https.go b/servers/https.go index 80b5839..ee93d22 100644 --- a/servers/https.go +++ b/servers/https.go @@ -9,7 +9,6 @@ import ( "github.com/sethvargo/go-limiter/httplimit" "github.com/sethvargo/go-limiter/memorystore" "log" - "net" "net/http" "path" "time" @@ -18,9 +17,16 @@ import ( // NewHttpsServer creates and runs a http server containing the public https // endpoints for the reverse proxy. func NewHttpsServer(conf *conf.Conf) *http.Server { + r := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + log.Printf("[Debug] Request: %s - '%s' - '%s' - '%s' - len: %d\n", req.Method, req.URL.String(), req.RemoteAddr, req.Host, req.ContentLength) + conf.Router.ServeHTTP(rw, req) + }) + favMiddleware := setupFaviconMiddleware(conf.Favicons, r) + rateLimiter := setupRateLimiter(conf.RateLimit, favMiddleware) + return &http.Server{ Addr: conf.HttpsListen, - Handler: setupRateLimiter(conf.RateLimit, setupFaviconMiddleware(conf.Favicons, conf.Router)), + Handler: rateLimiter, TLSConfig: &tls.Config{GetCertificate: func(info *tls.ClientHelloInfo) (*tls.Certificate, error) { // error out on invalid domains if !conf.Domains.IsValid(info.ServerName) { @@ -41,9 +47,6 @@ func NewHttpsServer(conf *conf.Conf) *http.Server { WriteTimeout: 150 * time.Second, IdleTimeout: 150 * time.Second, MaxHeaderBytes: 4096000, - ConnState: func(conn net.Conn, state http.ConnState) { - fmt.Printf("[HTTPS] %s => %s: %s\n", conn.LocalAddr(), conn.RemoteAddr(), state.String()) - }, } }