Chromium Code Reviews| Index: common/lhttp/utils.go |
| diff --git a/common/lhttp/utils.go b/common/lhttp/utils.go |
| index e2823be2a25a865607eef7f21b5f8768110cba58..f7d5181addd022c1d01cf7c690bfeab0c03f4d0d 100644 |
| --- a/common/lhttp/utils.go |
| +++ b/common/lhttp/utils.go |
| @@ -39,3 +39,17 @@ func CheckURL(s string) (string, error) { |
| } |
| return s, nil |
| } |
| + |
| +// IsLocalHost returns true if host is local. |
| +func IsLocalHost(host string) bool { |
| + switch { |
| + case host == "localhost", strings.HasPrefix(host, "localhost:"): |
| + case host == "127.0.0.1", strings.HasPrefix(host, "127.0.0.1:"): |
| + case host == "[::1]", strings.HasPrefix(host, "[::1]:"): |
|
Vadim Sh.
2016/08/09 19:09:24
strictly speaking 0:0:0:0:0:0:0:1 is also localhos
nodir
2016/08/09 22:56:31
Done.
|
| + case strings.HasPrefix(host, ":"): |
| + |
| + default: |
| + return false |
| + } |
| + return true |
| +} |