diff --git a/Makefile b/Makefile index 5de91c7..6e1fa83 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ all: - @echo "Usage: make server | make stop-server | make server-secret | make simple" + @echo "Usage: make server|stop-server|ovpn|start|stop|clean" server: @cd server && docker compose up --build -d @@ -10,9 +10,6 @@ stop-server: clean: @cd server && docker compose down -v -server-secret: - @cd server && printf 'Enter server secret: ' && read -r GS_SECRET && echo "GS_SECRET=$$GS_SECRET" > .env - ovpn: @docker cp gsocket-vpn:/vpn/client.ovpn . && echo 'client.ovpn saved!' diff --git a/README.md b/README.md index 52f93d0..f6ba528 100644 --- a/README.md +++ b/README.md @@ -31,32 +31,35 @@ Client-side dependencies: Assumes having Docker and Make. From the repo root: -1. Enter and save the GSocket secret: `make server-secret` -2. Build (if necessary) and start the server: `make server` -3. Export the `client.ovpn` file to the current directory: `make ovpn` -4. Stop the server (without removing the data): `make stop-server` -5. Stop the server and remove all data: `make clean` +1. Build (if necessary) and start the server: `make server` +2. Export the `client.ovpn` file to the current directory: `make ovpn` +3. Stop the server (without removing the data): `make stop-server` +4. Stop the server and remove all data: `make clean` + +Note: the `client.ovpn` file is the sole access key to the entire tunnel. Treat is as confidential data. ### On the client ("simple" approach, Make-based) 1. Get the `client.ovpn` file from the server and put it into the `client` directory. -2. Run `make start`, enter your GSocket server secret and then your sudo password (if necessary). +2. Run `make start` and then enter your sudo password (if necessary). 3. To stop the client, run `make stop.` ### On the client (manual approach, POSIX) 1. Get the `client.ovpn` file from the server. -2. Run these commands directly: `gs-netcat -D -s your_gsocket_secret -p 1194 && sudo openvpn --daemon gs-warp --config client.ovpn` -3. To stop, first stop the OpenVPN process and then gs-netcat. +2. Get the GS secret as the MD5 hash of the `client.ovpn` file: `export GS_SECRET=$(md5sum client.ovpn | cut -d ' ' -f 1)` +3. Run these commands directly: `gs-netcat -D -s $GS_SECRET -p 1194 && sudo openvpn --daemon gs-warp --config client.ovpn` +4. To stop, first stop the OpenVPN process and then gs-netcat. ### On the client (manual approach, non-POSIX) This is suitable for non-POSIX environments. You'll need any OpenVPN client and `gs-netcat` binary for your platform. 1. Get the `client.ovpn` file from the server and put it into your OpenVPN client's profile. Do not start the client yet. -2. In a separate terminal window, run `gs-netcat -D -s your_gsocket_secret -p 1194`. -3. Start the OpenVPN connection in the client. -4. To stop, first stop the OpenVPN connection and then terminate the gs-netcat process. +2. Get the GS secret as the MD5 hash of the `client.ovpn` file using whatever means available. +3. In a separate terminal window, run `gs-netcat -D -s $GS_SECRET -p 1194`. +4. Start the OpenVPN connection in the client. +5. To stop, first stop the OpenVPN connection and then terminate the gs-netcat process. More client options coming soon! diff --git a/client/gs-warp-simple.sh b/client/gs-warp-simple.sh index ee8339f..ea1fb18 100755 --- a/client/gs-warp-simple.sh +++ b/client/gs-warp-simple.sh @@ -1,8 +1,10 @@ #!/bin/sh -[ -z "$GS_SECRET" ] && GS_SECRET="$1" -[ -z "$GS_SECRET" ] && printf 'Enter GSocket secret: ' && read -r GS_SECRET +# Client-side GS-Warp launcher +# Created by Luxferre in 2026, released into the public domain + [ -z "$OVPNCFG" ] && OVPNCFG="$2" [ -z "$OVPNCFG" ] && OVPNCFG="client.ovpn" +GS_SECRET="$(md5sum "$OVPNCFG" | cut -d ' ' -f 1)" GSPIDFILE='/tmp/gswarp-gs.pid' OVPIDFILE='/tmp/gswarp-ov.pid' diff --git a/server/compose.yaml b/server/compose.yaml index cc9c82c..5fd2070 100644 --- a/server/compose.yaml +++ b/server/compose.yaml @@ -3,8 +3,6 @@ services: build: . container_name: gsocket-vpn restart: unless-stopped - environment: - - GS_SECRET=${GS_SECRET} dns: - 1.1.1.1 - 8.8.8.8 diff --git a/server/entrypoint.sh b/server/entrypoint.sh index 5d161b8..558bfaa 100644 --- a/server/entrypoint.sh +++ b/server/entrypoint.sh @@ -1,11 +1,8 @@ #!/usr/bin/env bash -set -e +# Server-side core (entrypoint) for GS-Warp +# Created by Luxferre in 2026, released into the public domain -if [ -z "$GS_SECRET" ]; then - echo "[!] ERROR: GS_SECRET environment variable is missing." - echo " Please start the container with -e GS_SECRET=\"your_secret_key\"" - exit 1 -fi +set -e # Ensure TUN device node exists in container namespace if [ ! -c /dev/net/tun ]; then @@ -151,5 +148,6 @@ openvpn --config /vpn/server.conf \ sleep 2 # 4. Forward GSocket stream directly to 127.0.0.1:1194 +GS_SECRET="$(md5sum /vpn/client.ovpn | cut -d ' ' -f 1)" echo "[+] Starting gs-netcat port forwarder..." exec gs-netcat -s "$GS_SECRET" -l -d 127.0.0.1 -p 1194