log web access
This commit is contained in:
7
httpd.go
7
httpd.go
@@ -118,12 +118,13 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
profile, _, _ := h.ovpn.AuthLoop(h.minProfile,
|
||||
strings.Replace(r.TLS.PeerCertificates[0].Subject.CommonName, " ", "", -1), "", false)
|
||||
webuser := strings.Replace(r.TLS.PeerCertificates[0].Subject.CommonName, " ", "", -1)
|
||||
profile, _, _ := h.ovpn.AuthLoop(h.minProfile, webuser, "", false)
|
||||
if profile != h.neededProfile {
|
||||
http.Error(w, fmt.Sprintf("You need the %s profile", h.neededProfile), 403)
|
||||
return
|
||||
}
|
||||
log.Printf("%s is connected via the web interfaces\n", webuser)
|
||||
|
||||
req, err := parseJsonQuery(r)
|
||||
if err != nil {
|
||||
@@ -141,7 +142,7 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "%s", jsonStr)
|
||||
|
||||
case "kill":
|
||||
if err := h.ovpn.Kill(req.Params.Session, req.Params.Id); err != nil {
|
||||
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, "{}")
|
||||
|
||||
Reference in New Issue
Block a user