Commit 064a7387 authored by ale's avatar ale
Browse files

fix withLocalhost: RemoteAddr is a host:port

parent e01cbaab
......@@ -371,7 +371,12 @@ func (h *HttpRedirector) serveStatusPage(w http.ResponseWriter, r *http.Request)
func withLocalhost(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if ip := net.ParseIP(r.RemoteAddr); !ip.IsLoopback() {
host, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
if ip := net.ParseIP(host); !ip.IsLoopback() {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment