Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Unified Diff: common/lhttp/utils.go

Issue 2227113002: Update bulidbucket client (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/cmd/buildbucket/put.go ('k') | dm/appengine/distributor/jobsim/run.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+}
« no previous file with comments | « client/cmd/buildbucket/put.go ('k') | dm/appengine/distributor/jobsim/run.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698