Browse Source

adjusting parameter names

pull/2/head
Chris Lu 12 years ago
parent
commit
3572e1140e
  1. 28
      go/weed/volume.go

28
go/weed/volume.go

@ -42,10 +42,10 @@ var (
vMaxCpu = cmdVolume.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
dataCenter = cmdVolume.Flag.String("dataCenter", "", "current volume server's data center name")
rack = cmdVolume.Flag.String("rack", "", "current volume server's rack name")
whiteListOption = cmdVolume.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")
volumeWhiteListOption = cmdVolume.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")
store *storage.Store
whiteList []string
volumeWhiteList []string
)
var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"")
@ -112,9 +112,9 @@ func storeHandler(w http.ResponseWriter, r *http.Request) {
case "HEAD":
GetOrHeadHandler(w, r, false)
case "DELETE":
secure(DeleteHandler)(w, r)
secure(volumeWhiteList, DeleteHandler)(w, r)
case "POST":
secure(PostHandler)(w, r)
secure(volumeWhiteList, PostHandler)(w, r)
}
}
func GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) {
@ -336,20 +336,20 @@ func runVolume(cmd *Command, args []string) bool {
if *publicUrl == "" {
*publicUrl = *ip + ":" + strconv.Itoa(*vport)
}
if *whiteListOption != "" {
whiteList = strings.Split(*whiteListOption, ",")
if *volumeWhiteListOption != "" {
volumeWhiteList = strings.Split(*volumeWhiteListOption, ",")
}
store = storage.NewStore(*vport, *ip, *publicUrl, folders, maxCounts)
defer store.Close()
http.HandleFunc("/", storeHandler)
http.HandleFunc("/submit", secure(submitFromVolumeServerHandler))
http.HandleFunc("/status", secure(statusHandler))
http.HandleFunc("/admin/assign_volume", secure(assignVolumeHandler))
http.HandleFunc("/admin/vacuum_volume_check", secure(vacuumVolumeCheckHandler))
http.HandleFunc("/admin/vacuum_volume_compact", secure(vacuumVolumeCompactHandler))
http.HandleFunc("/admin/vacuum_volume_commit", secure(vacuumVolumeCommitHandler))
http.HandleFunc("/admin/freeze_volume", secure(freezeVolumeHandler))
http.HandleFunc("/submit", secure(volumeWhiteList, submitFromVolumeServerHandler))
http.HandleFunc("/status", secure(volumeWhiteList, statusHandler))
http.HandleFunc("/admin/assign_volume", secure(volumeWhiteList, assignVolumeHandler))
http.HandleFunc("/admin/vacuum_volume_check", secure(volumeWhiteList, vacuumVolumeCheckHandler))
http.HandleFunc("/admin/vacuum_volume_compact", secure(volumeWhiteList, vacuumVolumeCompactHandler))
http.HandleFunc("/admin/vacuum_volume_commit", secure(volumeWhiteList, vacuumVolumeCommitHandler))
http.HandleFunc("/admin/freeze_volume", secure(volumeWhiteList, freezeVolumeHandler))
go func() {
connected := true
@ -386,7 +386,7 @@ func runVolume(cmd *Command, args []string) bool {
return true
}
func secure(f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
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)

Loading…
Cancel
Save