Skip to content

Commit

Permalink
Assume net.SplitHostPort error means local address
Browse files Browse the repository at this point in the history
  • Loading branch information
dsamarin committed May 6, 2018
1 parent 242190d commit 7b9719a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions util.go
Expand Up @@ -29,12 +29,8 @@ func ParseSocketName(value string) (string, string) {
// or the RemoteAddr property if the header does not exist.
func RealRemoteIP(r *http.Request) net.IP {
// When local, RemoteAddr is empty.
if r.RemoteAddr != "" {
host, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
return nil
}

host, _, err := net.SplitHostPort(r.RemoteAddr)
if err == nil {
ip := net.ParseIP(host)
if ip == nil {
return nil
Expand Down

0 comments on commit 7b9719a

Please sign in to comment.