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