exclude asn blocking on asset routes; properly fallback title status number

This commit is contained in:
2026-11-22 22:13:39 -05:00
parent 1834abc719
commit 993b6317a5
2 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -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) { 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") { if strings.Contains(r.Header.Get("Accept"), "text/html") {
t := fmt.Sprintf("%c", status) t := fmt.Sprintf("errror %d", status)
if len(title) > 0 { if len(title) > 0 {
t = title[0] t = title[0]
} }
+8 -3
View File
@@ -56,14 +56,19 @@ func NewRouter(db *gorm.DB, cfg config.Config, p *pages.Pages, tracker *uploads.
mux.HandleFunc("GET /health", health) mux.HandleFunc("GET /health", health)
if len(cfg.BannedClientASNs) > 0 && len(asnMMDB) > 0 { if len(cfg.BannedClientASNs) > 0 && len(asnMMDB) > 0 {
ammdb := asnMMDB[0]
blocker := &middleware.ASNBlocker{ blocker := &middleware.ASNBlocker{
DB: ammdb, DB: asnMMDB[0],
Blocked: cfg.BannedClientASNs, Blocked: cfg.BannedClientASNs,
ResolveIP: cipr, ResolveIP: cipr,
Pages: p, 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 return mux
} }