refactoring for later security changes
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -72,25 +71,6 @@ func debug(params ...interface{}) {
|
||||
glog.V(4).Infoln(params)
|
||||
}
|
||||
|
||||
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})
|
||||
}
|
||||
}
|
||||
|
||||
func submitForClientHandler(w http.ResponseWriter, r *http.Request, masterUrl string) {
|
||||
m := make(map[string]interface{})
|
||||
if r.Method != "POST" {
|
||||
|
||||
Reference in New Issue
Block a user