This commit is contained in:
9
main.go
9
main.go
@@ -218,10 +218,6 @@ var (
|
|||||||
|
|
||||||
// Prometheus Metriken
|
// Prometheus Metriken
|
||||||
var (
|
var (
|
||||||
checkRequests = prometheus.NewCounter(prometheus.CounterOpts{
|
|
||||||
Name: "ipcheck_requests_total",
|
|
||||||
Help: "Total IP check requests",
|
|
||||||
})
|
|
||||||
checkBlocked = prometheus.NewCounter(prometheus.CounterOpts{
|
checkBlocked = prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
Name: "ipcheck_blocked_total",
|
Name: "ipcheck_blocked_total",
|
||||||
Help: "Total blocked IPs",
|
Help: "Total blocked IPs",
|
||||||
@@ -240,7 +236,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
prometheus.MustRegister(checkRequests, checkBlocked, checkWhitelist, blocklistHashSizes)
|
prometheus.MustRegister(checkBlocked, checkWhitelist, blocklistHashSizes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
@@ -547,7 +543,6 @@ func handleCheck(w http.ResponseWriter, r *http.Request) {
|
|||||||
Username: os.Getenv("REDIS_USER"),
|
Username: os.Getenv("REDIS_USER"),
|
||||||
Password: os.Getenv("REDIS_PASS"),
|
Password: os.Getenv("REDIS_PASS"),
|
||||||
})
|
})
|
||||||
checkRequests.Inc()
|
|
||||||
ipStr := strings.TrimPrefix(r.URL.Path, "/check/")
|
ipStr := strings.TrimPrefix(r.URL.Path, "/check/")
|
||||||
ip, err := netip.ParseAddr(ipStr)
|
ip, err := netip.ParseAddr(ipStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -590,8 +585,6 @@ func handleTraefik(w http.ResponseWriter, r *http.Request) {
|
|||||||
Password: os.Getenv("REDIS_PASS"),
|
Password: os.Getenv("REDIS_PASS"),
|
||||||
})
|
})
|
||||||
|
|
||||||
checkRequests.Inc()
|
|
||||||
|
|
||||||
ip, err := clientIPFromHeaders(r)
|
ip, err := clientIPFromHeaders(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "invalid IP", http.StatusBadRequest)
|
http.Error(w, "invalid IP", http.StatusBadRequest)
|
||||||
|
|||||||
Reference in New Issue
Block a user