feat: print command aprsing error
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
parent
88effa0889
commit
1470ec8629
@ -21,7 +21,6 @@ var upgrader = websocket.Upgrader{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cmdNotImplemented = []byte("Command not implemented.")
|
|
||||||
cmdNotAllowed = []byte("Command not allowed.")
|
cmdNotAllowed = []byte("Command not allowed.")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -63,6 +62,15 @@ func (e *Env) commandsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
command, err := e.Settings.ParseCommand(raw)
|
command, err := e.Settings.ParseCommand(raw)
|
||||||
|
if err != nil {
|
||||||
|
err := conn.WriteMessage(websocket.TextMessage, []byte(err.Error()))
|
||||||
|
if err != nil {
|
||||||
|
wsErr(conn, r, http.StatusInternalServerError, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
path := strings.TrimPrefix(r.URL.Path, "/api/command")
|
path := strings.TrimPrefix(r.URL.Path, "/api/command")
|
||||||
dir := afero.FullBaseFsPath(user.Fs.(*afero.BasePathFs), path)
|
dir := afero.FullBaseFsPath(user.Fs.(*afero.BasePathFs), path)
|
||||||
cmd := exec.Command(command[0], command[1:]...)
|
cmd := exec.Command(command[0], command[1:]...)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user