add white list to both master and volume servers

prepare for v0.41
This commit is contained in:
Chris Lu
2013-08-13 09:31:19 -07:00
parent 3572e1140e
commit e45c6b5e21
4 changed files with 46 additions and 41 deletions

View File

@@ -7,7 +7,6 @@ import (
"code.google.com/p/weed-fs/go/storage"
"math/rand"
"mime"
"net"
"net/http"
"os"
"path/filepath"
@@ -385,22 +384,3 @@ func runVolume(cmd *Command, args []string) bool {
}
return true
}
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})
}
}