faucet: check ip length

This commit is contained in:
emailtovamos 2024-07-23 17:47:07 +01:00
parent cd3539ab18
commit a85215cd70

@ -287,7 +287,9 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
ip := r.RemoteAddr
if len(r.Header.Get("X-Forwarded-For")) > 0 {
ips := strings.Split(r.Header.Get("X-Forwarded-For"), ",")
ip = strings.TrimSpace(ips[len(ips)-1])
if len(ips) > 0 {
ip = strings.TrimSpace(ips[len(ips)-1])
}
}
limiter := f.limiter.GetLimiter(ip)