Skip to content

Commit

Permalink
#patch: use net package for determining if loopback address
Browse files Browse the repository at this point in the history
  • Loading branch information
circa10a committed Feb 26, 2022
1 parent f16cd7d commit a273064
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions caddy_geofence.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"net"
"net/http"
"strings"
"time"

"github.com/caddyserver/caddy/v2"
Expand Down Expand Up @@ -158,7 +157,7 @@ func (cg CaddyGeofence) ServeHTTP(w http.ResponseWriter, r *http.Request, next c
// isPrivateAddress checks if remote address is from known private ip space
func isPrivateAddress(addr string) bool {
ip := net.ParseIP(addr)
return ip.IsPrivate() || strings.HasPrefix(addr, "::1")
return ip.IsPrivate() || ip.IsLoopback()
}

// strInSlice returns true if string is in slice
Expand Down

0 comments on commit a273064

Please sign in to comment.