exclude asn blocking on asset routes; properly fallback title status number
This commit is contained in:
@@ -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]
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user