geoblock icon indicating copy to clipboard operation
geoblock copied to clipboard

Trim ip address before feeding this to the net lib

Open thubolt opened this issue 9 months ago • 1 comments

I noticed the following:

The ip address that traefik passed through to the middleware contained a whitespace.

In geoblock.go at line 459 the addr string is passed untrimmed to the net library.

func parseIP(addr string) (net.IP, error) {
    ipAddress := net.ParseIP(addr)

    if ipAddress == nil {
       return nil, fmt.Errorf("unable parse IP address from address [%s]", addr)
    }

    return ipAddress, nil
}

This results in the error "unable parse IP address from address..." It wil help us if at this point addr is trimmed off whitespaces.

thubolt avatar Apr 11 '25 09:04 thubolt