-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
003dbe8
commit 6718804
Showing
24 changed files
with
1,807 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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 = true | ||
|
||
[color] | ||
app = "" | ||
build = "yellow" | ||
main = "magenta" | ||
runner = "green" | ||
watcher = "cyan" | ||
|
||
[log] | ||
main_only = 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PROXMOX_USERNAME=root@pam | ||
PROXMOX_PASSWORD=password | ||
PROXMOX_URL=https://192.168.0.200:8006/api2/json | ||
PROXMOX_NODE=proxmox5 | ||
PROXMOX_VM=216 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
tmp/ | ||
|
||
# Go workspace file | ||
go.work | ||
go.work.sum | ||
|
||
# env file | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Proxmox VNC and Terminal Proxy | ||
|
||
This project provides a Go-based server for interacting with Proxmox virtual machines via VNC and terminal proxies. The server supports secure WebSocket connections and can be accessed through a simple web client. | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
- Go 1.18 or higher | ||
- OpenSSL for generating SSL certificates | ||
- Proxmox environment with a valid configuration | ||
|
||
### Installation | ||
|
||
1. **Generate SSL Certificates** | ||
|
||
Create self-signed SSL certificates for secure communication: | ||
|
||
```bash | ||
openssl req -newkey rsa:2048 -nodes -keyout server.key -x509 -days 365 -out server.crt | ||
``` | ||
|
||
2. **Create the `.env` File** | ||
|
||
Add the following environment variables to a `.env` file in the root directory: | ||
|
||
```plaintext | ||
PROXMOX_USERNAME=root@pam | ||
PROXMOX_PASSWORD=password | ||
PROXMOX_URL=https://192.168.0.200:8006/api2/json | ||
PROXMOX_NODE=proxmox5 | ||
PROXMOX_VM=216 | ||
``` | ||
|
||
3. **Install Dependencies** | ||
|
||
Install the necessary Go modules: | ||
|
||
```bash | ||
go mod tidy | ||
``` | ||
|
||
### Running the Server | ||
|
||
Start the server with SSL enabled: | ||
|
||
```bash | ||
go run main.go | ||
``` | ||
|
||
The server will be accessible at `https://localhost:8523`. | ||
|
||
### Endpoints | ||
|
||
- **`/`**: Returns "hello world". | ||
- **`/term`**: WebSocket endpoint for terminal access. | ||
- **`/vnc`**: WebSocket endpoint for VNC access. Requires a valid ticket. | ||
- **`/vnc-ticket`**: Generates and returns a VNC ticket. | ||
|
||
### Code Overview | ||
|
||
- **`main.go`**: The main application file that sets up the server and routes. | ||
- **`impl/term.go`**: Contains the implementation for the terminal WebSocket endpoint. | ||
- **`impl/vnc.go`**: Contains the implementation for the VNC WebSocket endpoint and ticket generation. | ||
|
||
### Code Overview | ||
|
||
- **`main.go`**: The main application file that sets up the server and routes. It configures logging, loads environment variables, and starts the server with SSL. | ||
|
||
- **`impl/term.go`**: Contains the implementation for the terminal WebSocket endpoint. It sets up a WebSocket connection for terminal access and handles communication between the client and the Proxmox virtual machine. | ||
|
||
- **`impl/vnc.go`**: Contains the implementation for the VNC WebSocket endpoint and ticket generation. It manages VNC connections and tickets: | ||
- The `tickets` map is used for learning purposes to store VNC tickets temporarily. In a real-world scenario, you should store tickets in a distributed cache or a persistent storage solution. | ||
- It is also possible to use a password instead of a ticket for authentication. | ||
|
||
### Acknowledgments | ||
|
||
A big thank you to ChatGPT for helping with the documentation and code improvements! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module term-and-vnc | ||
|
||
go 1.22.0 | ||
|
||
replace github.com/luthermonson/go-proxmox => ../../ | ||
|
||
require ( | ||
github.com/gin-contrib/cors v1.7.2 | ||
github.com/gin-gonic/gin v1.10.0 | ||
github.com/gorilla/websocket v1.5.3 | ||
github.com/joho/godotenv v1.5.1 | ||
github.com/luthermonson/go-proxmox v0.1.1 | ||
github.com/rs/zerolog v1.33.0 | ||
) | ||
|
||
require ( | ||
github.com/buger/goterm v1.0.4 // indirect | ||
github.com/bytedance/sonic v1.11.6 // indirect | ||
github.com/bytedance/sonic/loader v0.1.1 // indirect | ||
github.com/cloudwego/base64x v0.1.4 // indirect | ||
github.com/cloudwego/iasm v0.2.0 // indirect | ||
github.com/diskfs/go-diskfs v1.2.0 // indirect | ||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect | ||
github.com/gin-contrib/sse v0.1.0 // indirect | ||
github.com/go-playground/locales v0.14.1 // indirect | ||
github.com/go-playground/universal-translator v0.18.1 // indirect | ||
github.com/go-playground/validator/v10 v10.20.0 // indirect | ||
github.com/goccy/go-json v0.10.2 // indirect | ||
github.com/jinzhu/copier v0.3.4 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect | ||
github.com/leodido/go-urn v1.4.0 // indirect | ||
github.com/magefile/mage v1.14.0 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect | ||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect | ||
github.com/ugorji/go/codec v1.2.12 // indirect | ||
golang.org/x/arch v0.8.0 // indirect | ||
golang.org/x/crypto v0.23.0 // indirect | ||
golang.org/x/net v0.25.0 // indirect | ||
golang.org/x/sys v0.20.0 // indirect | ||
golang.org/x/text v0.15.0 // indirect | ||
google.golang.org/protobuf v1.34.1 // indirect | ||
gopkg.in/djherbis/times.v1 v1.2.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
Oops, something went wrong.