From 993b6317a5fa1da163485e061480d59fb030c5ee Mon Sep 17 00:00:00 2001 From: whoswhip Date: Sun, 22 Nov 2026 22:13:39 -0500 Subject: [PATCH] exclude asn blocking on asset routes; properly fallback title status number --- internal/pages/pages.go | 2 +- internal/server/routes.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/pages/pages.go b/internal/pages/pages.go index c4acaf0..7573fdc 100644 --- a/internal/pages/pages.go +++ b/internal/pages/pages.go @@ -140,7 +140,7 @@ func FaqHandler(pages *Pages, cfg config.Config) http.HandlerFunc { func (pages *Pages) HTTPError(w http.ResponseWriter, r *http.Request, message string, status int, title ...string) { if strings.Contains(r.Header.Get("Accept"), "text/html") { - t := fmt.Sprintf("%c", status) + t := fmt.Sprintf("errror %d", status) if len(title) > 0 { t = title[0] } diff --git a/internal/server/routes.go b/internal/server/routes.go index 9adbfea..fd696a2 100644 --- a/internal/server/routes.go +++ b/internal/server/routes.go @@ -56,14 +56,19 @@ func NewRouter(db *gorm.DB, cfg config.Config, p *pages.Pages, tracker *uploads. mux.HandleFunc("GET /health", health) if len(cfg.BannedClientASNs) > 0 && len(asnMMDB) > 0 { - ammdb := asnMMDB[0] blocker := &middleware.ASNBlocker{ - DB: ammdb, + DB: asnMMDB[0], Blocked: cfg.BannedClientASNs, ResolveIP: cipr, Pages: p, } - return blocker.BlockASN(mux) + + outer := http.NewServeMux() + for _, path := range []string{"/qts/", "/static/", "/js/", "/css/"} { + outer.Handle("GET "+path, mux) + } + outer.Handle("/", blocker.BlockASN(mux)) + return outer } return mux }