blank state
This commit is contained in:
18
httpd.go
18
httpd.go
@@ -119,11 +119,9 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
webuser := strings.Replace(r.TLS.PeerCertificates[0].Subject.CommonName, " ", "", -1)
|
||||
_, _, _, profilePath := h.ovpn.AuthLoop(h.minProfile, webuser, "", false)
|
||||
if !inArray(h.neededProfiles, profilePath) {
|
||||
http.Error(w, fmt.Sprintf("You need on of %s profile and you have %s", h.neededProfiles, profilePath), 403)
|
||||
return
|
||||
}
|
||||
|
||||
//TODO security
|
||||
|
||||
log.Printf("%s is connected via the web interfaces\n", webuser)
|
||||
|
||||
req, err := parseJsonQuery(r)
|
||||
@@ -135,17 +133,7 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
switch req.Action {
|
||||
case "stats":
|
||||
jsonStr, err := json.Marshal(h.ovpn.Stats())
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("%s", err), 500)
|
||||
}
|
||||
fmt.Fprintf(w, "%s", jsonStr)
|
||||
|
||||
case "kill":
|
||||
if err := h.ovpn.Kill(req.Params.Session, req.Params.Id, webuser); err != nil {
|
||||
http.Error(w, fmt.Sprintf("%s", err), 500)
|
||||
}
|
||||
fmt.Fprintf(w, "{}")
|
||||
default:
|
||||
http.Error(w, "Invalid request", 500)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user