diff --git a/.gitignore b/.gitignore index b831f99..0b6a78d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ config .quest +tmp # Logs logs diff --git a/.vscode/settings.json b/.vscode/settings.json index fd4883f..1aa2f62 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,8 @@ "editor.formatOnSave": true, "yaml.schemas": { "packages/game/quest.json": "quests/**/game.yml" + }, + "[go]": { + "editor.defaultFormatter": "golang.go" } } diff --git a/terminal-service/.air.toml b/terminal-service/.air.toml new file mode 100644 index 0000000..498951f --- /dev/null +++ b/terminal-service/.air.toml @@ -0,0 +1,52 @@ +root = "." +testdata_dir = "testdata" +tmp_dir = "tmp" + +[build] + args_bin = [] + bin = "./tmp/main" + cmd = "go build -o ./tmp/main ." + delay = 1000 + exclude_dir = ["assets", "tmp", "vendor", "testdata"] + exclude_file = [] + exclude_regex = ["_test.go"] + exclude_unchanged = false + follow_symlink = false + full_bin = "" + include_dir = [] + include_ext = ["go", "tpl", "tmpl", "html"] + include_file = [] + kill_delay = "0s" + log = "build-errors.log" + poll = false + poll_interval = 0 + post_cmd = [] + pre_cmd = [] + rerun = false + rerun_delay = 500 + send_interrupt = false + stop_on_error = false + +[color] + app = "" + build = "yellow" + main = "magenta" + runner = "green" + watcher = "cyan" + +[log] + main_only = false + silent = false + time = false + +[misc] + clean_on_exit = false + +[proxy] + app_port = 0 + enabled = false + proxy_port = 0 + +[screen] + clear_on_rebuild = false + keep_scroll = true diff --git a/terminal-service/README.md b/terminal-service/README.md new file mode 100644 index 0000000..61865d9 --- /dev/null +++ b/terminal-service/README.md @@ -0,0 +1,56 @@ +# Terminal Service + +A lightweight terminal service for Linux Odyssey player containers, replacing SSH with a more efficient WebSocket-based solution. + +## Features + +- WebSocket-based terminal sessions +- PTY (pseudo-terminal) management +- Quest command execution +- File status and content inspection +- Direct integration with Traefik for frontend access + +## Architecture + +The service is designed to be lightweight and efficient, using: + +- gorilla/websocket for WebSocket connections +- creack/pty for terminal management +- Traefik for reverse proxying + +## Development + +### Prerequisites + +- Go 1.24 or later +- Docker and Docker Compose +- Traefik (for production deployment) + +### Setup + +1. Install dependencies: + +```bash +go mod init github.com/linux-odyssey/linux-odyssey/terminal-service +go get github.com/gorilla/websocket +go get github.com/creack/pty +``` + +2. Build and run: + +```bash +go build +./terminal-service +``` + +## Configuration + +Configuration details will be added as the service develops. + +## Security + +The service implements security measures to ensure safe container access and command execution. + +## License + +Same as the main Linux Odyssey project. diff --git a/terminal-service/go.mod b/terminal-service/go.mod new file mode 100644 index 0000000..8530e2c --- /dev/null +++ b/terminal-service/go.mod @@ -0,0 +1,10 @@ +module github.com/linux-odyssey/linux-odyssey/terminal-service + +go 1.24.2 + +require ( + github.com/creack/pty v1.1.24 // indirect + github.com/gorilla/websocket v1.5.3 // indirect + golang.org/x/sys v0.32.0 // indirect + golang.org/x/term v0.31.0 // indirect +) diff --git a/terminal-service/go.sum b/terminal-service/go.sum new file mode 100644 index 0000000..5ba15ab --- /dev/null +++ b/terminal-service/go.sum @@ -0,0 +1,8 @@ +github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= +github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= +golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= diff --git a/terminal-service/index.html b/terminal-service/index.html new file mode 100644 index 0000000..738a22e --- /dev/null +++ b/terminal-service/index.html @@ -0,0 +1,82 @@ + + +
+