diff --git a/build/docker/prod/Dockerfile b/build/docker/prod/Dockerfile index aa9450da..96697df5 100644 --- a/build/docker/prod/Dockerfile +++ b/build/docker/prod/Dockerfile @@ -27,11 +27,19 @@ COPY dashboard ./ RUN yarn run build -FROM ubuntu:xenial-20200706 - +FROM debian:stable-slim +USER root WORKDIR /trasa +ENV GUACENC_INSTALLED=true +COPY --from=seknox/guacd:v0.0.1 /usr/local/guacamole/bin/guacenc /usr/local/guacamole/bin/guacenc +COPY --from=seknox/guacd:v0.0.1 /usr/local/guacamole/lib/ /usr/local/guacamole/lib/ +COPY --from=seknox/guacd:v0.0.1 /usr/local/guacamole/DEPENDENCIES /usr/local/guacamole/ + RUN apt-get update RUN apt-get install -y --no-install-recommends ca-certificates +RUN apt-get install -y libavcodec-dev libavformat-dev libavutil-dev libswscale-dev ffmpeg +RUN apt-get install -y $(cat /usr/local/guacamole/DEPENDENCIES) + RUN update-ca-certificates COPY --from=gobuilder /go/src/seknox/trasa/server/server . COPY --from=dashbuilder /trasa/build /var/trasa/dashboard diff --git a/build/etc/trasa/config/config.toml b/build/etc/trasa/config/config.toml index a4886d13..bf2c3e5b 100644 --- a/build/etc/trasa/config/config.toml +++ b/build/etc/trasa/config/config.toml @@ -42,7 +42,7 @@ sshlistenAddr = "127.0.0.1:8022" dbListenAddr = "127.0.0.1:3333" guacdEnabled = false - guacdAddr = "127.0.0.1:4822" + guacdAddr = "guacd:4822" [vault] diff --git a/server/accessproxy/rdpproxy/store.go b/server/accessproxy/rdpproxy/store.go index a8d47266..53cb53bf 100644 --- a/server/accessproxy/rdpproxy/store.go +++ b/server/accessproxy/rdpproxy/store.go @@ -88,7 +88,7 @@ func (s GWStore) uploadSessionLog(authlog *logs.AuthLog) error { func getGuacencCmd(sessionID string) *exec.Cmd { if os.Getenv("GUACENC_INSTALLED") == "true" { guacencCmdStr := fmt.Sprintf( - "/usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID) + "nice -n 10 /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID) return exec.Command("/bin/sh", "-c", guacencCmdStr) @@ -96,26 +96,32 @@ func getGuacencCmd(sessionID string) *exec.Cmd { if runtime.GOOS == "windows" { guacencCmdStr := fmt.Sprintf( - "docker.exe exec guacd /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID) + "docker.exe exec guacd nice -n 10 /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID) return exec.Command("powershell", "-c", guacencCmdStr) } guacencCmdStr := fmt.Sprintf( - "sudo docker exec guacd /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID) + "sudo docker exec guacd nice -n 10 /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID) return exec.Command("/bin/bash", "-c", guacencCmdStr) } func getFFMPEGcmd(tempFileDir, sessionID string) *exec.Cmd { + if os.Getenv("GUACENC_INSTALLED") == "true" { + ffmpegCmdStr := fmt.Sprintf("nice -n 10 ffmpeg -i %s/%s.guac.m4v %s/%s.mp4", tempFileDir, sessionID, tempFileDir, sessionID) + return exec.Command("/bin/bash", "-c", ffmpegCmdStr) + + } + if runtime.GOOS == "windows" { ffmpegCmdStr := fmt.Sprintf(`ffmpeg.exe -i %s\%s.guac.m4v %s\%s.mp4`, tempFileDir, sessionID, tempFileDir, sessionID) return exec.Command("powershell", "-c", ffmpegCmdStr) } - ffmpegCmdStr := fmt.Sprintf("sudo ffmpeg -i %s/%s.guac.m4v %s/%s.mp4", tempFileDir, sessionID, tempFileDir, sessionID) + ffmpegCmdStr := fmt.Sprintf("sudo nice -n 10 ffmpeg -i %s/%s.guac.m4v %s/%s.mp4", tempFileDir, sessionID, tempFileDir, sessionID) return exec.Command("/bin/bash", "-c", ffmpegCmdStr) } diff --git a/server/api/logs/store.go b/server/api/logs/store.go index fd297b8d..606a2b9f 100644 --- a/server/api/logs/store.go +++ b/server/api/logs/store.go @@ -312,7 +312,7 @@ func (s logStore) PutIntoMinio(objectName, logfilepath, bucketName string) error if err != nil { return err } - return os.Rename(logfilepath, newpath) + return utils.MoveFile(logfilepath, newpath) } diff --git a/server/utils/filesystem.go b/server/utils/filesystem.go index eb1b1aa3..5f2dcf77 100644 --- a/server/utils/filesystem.go +++ b/server/utils/filesystem.go @@ -1,6 +1,8 @@ package utils import ( + "fmt" + "io" "os" "runtime" @@ -17,6 +19,30 @@ func CreateDirIfNotExist(dir string) { } } +func MoveFile(sourcePath, destPath string) error { + inputFile, err := os.Open(sourcePath) + if err != nil { + return fmt.Errorf("Couldn't open source file: %s", err) + } + outputFile, err := os.Create(destPath) + if err != nil { + inputFile.Close() + return fmt.Errorf("Couldn't open dest file: %s", err) + } + defer outputFile.Close() + _, err = io.Copy(outputFile, inputFile) + inputFile.Close() + if err != nil { + return fmt.Errorf("Writing to output file failed: %s", err) + } + // The copy was successful, so now delete the original file + err = os.Remove(sourcePath) + if err != nil { + return fmt.Errorf("Failed removing original file: %s", err) + } + return nil +} + func GetETCDir() string { switch runtime.GOOS { case "windows":