mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-14 22:56:17 +08:00
issue 43 "go fmt" chagnes from "Ryan S. Brown" <sb@ryansb.com>
some basic changes to parse upload url
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -225,20 +225,20 @@ func debug(params ...interface{}) {
|
||||
}
|
||||
}
|
||||
func secure(whiteList []string, f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if len(whiteList) == 0 {
|
||||
f(w, r)
|
||||
return
|
||||
}
|
||||
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err == nil {
|
||||
for _, ip := range whiteList {
|
||||
if ip == host {
|
||||
f(w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
writeJsonQuiet(w, r, map[string]interface{}{"error": "No write permisson from " + host})
|
||||
}
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if len(whiteList) == 0 {
|
||||
f(w, r)
|
||||
return
|
||||
}
|
||||
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err == nil {
|
||||
for _, ip := range whiteList {
|
||||
if ip == host {
|
||||
f(w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
writeJsonQuiet(w, r, map[string]interface{}{"error": "No write permisson from " + host})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user