| Index: common/lhttp/utils.go
|
| diff --git a/common/lhttp/utils.go b/common/lhttp/utils.go
|
| index e2823be2a25a865607eef7f21b5f8768110cba58..d4bda7c05063e952ae0736a8957299fa38974e83 100644
|
| --- a/common/lhttp/utils.go
|
| +++ b/common/lhttp/utils.go
|
| @@ -6,6 +6,7 @@ package lhttp
|
|
|
| import (
|
| "errors"
|
| + "net"
|
| "net/url"
|
| "strings"
|
| )
|
| @@ -39,3 +40,19 @@ func CheckURL(s string) (string, error) {
|
| }
|
| return s, nil
|
| }
|
| +
|
| +// IsLocalHost returns true if hostport is local.
|
| +func IsLocalHost(hostport string) bool {
|
| + host, _, err := net.SplitHostPort(hostport)
|
| + if err != nil {
|
| + return false
|
| + }
|
| + switch {
|
| + case host == "localhost", host == "":
|
| + case net.ParseIP(host).IsLoopback():
|
| +
|
| + default:
|
| + return false
|
| + }
|
| + return true
|
| +}
|
|
|