From 6915f6c5c1be77ad9f4a1d47ffadb8bba2607c74 Mon Sep 17 00:00:00 2001 From: yangshukui Date: Tue, 8 Mar 2016 14:41:14 +0800 Subject: [PATCH] fix allowhost Signed-off-by: yangshukui --- contrib/analyze-local-images/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/analyze-local-images/main.go b/contrib/analyze-local-images/main.go index e1e2b4af..9f67d5f7 100644 --- a/contrib/analyze-local-images/main.go +++ b/contrib/analyze-local-images/main.go @@ -22,6 +22,7 @@ import ( "flag" "fmt" "io/ioutil" + "net" "net/http" "os" "os/exec" @@ -257,7 +258,8 @@ func listenHTTP(path, allowedHost string) { restrictedFileServer := func(path, allowedHost string) http.Handler { fc := func(w http.ResponseWriter, r *http.Request) { - if r.Host == allowedHost { + host, _, err := net.SplitHostPort(r.RemoteAddr) + if err == nil && strings.EqualFold(host, allowedHost) { http.FileServer(http.Dir(path)).ServeHTTP(w, r) return }