Basic auth
This commit is contained in:
8
httpd.go
8
httpd.go
@@ -20,6 +20,8 @@ type jsonInput struct {
|
||||
type jsonInputParams struct {
|
||||
Server string `json:"server"`
|
||||
Session int `json:"session"`
|
||||
User string `json:"user"`
|
||||
Pass string `json:"password"`
|
||||
}
|
||||
|
||||
type HttpServer struct {
|
||||
@@ -74,14 +76,16 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "Invalid request", 500)
|
||||
return
|
||||
}
|
||||
h.ovpn.Debug(req)
|
||||
|
||||
h.ovpn.Debug(req.Action)
|
||||
switch req.Action {
|
||||
case "get-remotes":
|
||||
jsonStr, err = json.Marshal(h.ovpn)
|
||||
case "set-remote":
|
||||
err = h.ovpn.SetRemote(req.Params.Server, req.Params.Session)
|
||||
jsonStr = []byte("{\"status\": \"ok\"}")
|
||||
case "auth-user-pass":
|
||||
err = h.ovpn.AuthUserPass(req.Params.Session, req.Params.User, req.Params.Pass)
|
||||
jsonStr = []byte("{\"status\": \"ok\"}")
|
||||
case "get-sessions":
|
||||
jsonStr, err = json.Marshal(h.ovpn)
|
||||
case "version":
|
||||
|
||||
Reference in New Issue
Block a user