diff --git a/httpd.go b/httpd.go index 71158f9..ad5838b 100644 --- a/httpd.go +++ b/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, "{}") diff --git a/vpnserver.go b/vpnserver.go index 69fc122..f3cbb83 100644 --- a/vpnserver.go +++ b/vpnserver.go @@ -122,13 +122,14 @@ func (s *OpenVpnMgt) Stats() map[string]map[int]*vpnSession { return s.clients } -func (s *OpenVpnMgt) Kill(session string, id int) error { +func (s *OpenVpnMgt) Kill(session string, id int, killer string) error { if _, ok := s.clients[session]; !ok { return errors.New("unknown session") } if _, ok := s.clients[session][id]; !ok { return errors.New("unknown session id") } + log.Printf("user %s's session killed from the web by %s\n", s.clients[session][id].Login, killer) err, _ := s.sendCommand([]string{fmt.Sprintf("client-kill %d", id)}, session) return err }