This commit is contained in:
3
main.go
3
main.go
@@ -268,12 +268,13 @@ func authHandler(st *state) http.Handler {
|
||||
return
|
||||
}
|
||||
if decide(st, ip) {
|
||||
// optional: reflect info for debugging
|
||||
log.Printf("Allowed: %s", ip)
|
||||
w.Header().Set("X-IPFilter-Client", ip.String())
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte("OK"))
|
||||
return
|
||||
}
|
||||
log.Printf("Blocked: %s", ip)
|
||||
w.Header().Set("X-IPFilter-Client", ip.String())
|
||||
http.Error(w, "forbidden by ip filter", http.StatusForbidden)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user