Files
proxy-suite-flake/windows/tools/dev-service.sh
T
faumarayandClaude Opus 5.5 63aede0dc1 windows: the service names zapret's presets and tg-ws-proxy's links
- zapret-presets: the presets of the installed zapret release and the one
  configured; proxy-ctl zapret presets.
- tg-links: tg-ws-proxy's tg:// links (dd, and ee with a fake-TLS
  domain), as it prints them; they carry its secret, so the secrets scope.
  proxy-ctl tg link. No more reading them out of its log.
- tools/dev-service.sh: the service on Linux with a demo outbound, for
  working on the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:18:59 +03:00

52 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# The service on Linux, for working on the app: console mode with its own state directory and
# socket, a local sing-box Shadowsocks server as a demo outbound, and the zapret presets of a
# built release (tools/package.sh) when there is one. In the dev shell:
#
# tools/dev-service.sh [STATE_DIR] (Ctrl-C stops it all)
# cargo run -p ps-gui -- --socket "$XDG_RUNTIME_DIR/proxy-suite-dev.sock"
#
# The socket is not in STATE_DIR: a Unix socket's path is limited to about 100 bytes.
set -euo pipefail
cd "$(dirname "$0")/.."
STATE=$(realpath -m "${1:-${TMPDIR:-/tmp}/proxy-suite-dev}")
mkdir -p "$STATE"
SOCK=${SOCK:-${XDG_RUNTIME_DIR:-/tmp}/proxy-suite-dev.sock}
free_port() { python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1])'; }
# Chosen once and kept, as the configuration that names them is.
if [ ! -f "$STATE/ports" ]; then
echo "SS=$(free_port) PROXY=$(free_port) CLASH=$(free_port) TEST=$(free_port)" >"$STATE/ports"
fi
. "$STATE/ports"
KEY=a2tra2tra2tra2tra2traw==
cat >"$STATE/server.json" <<EOF
{ "log": { "level": "warn" },
"inbounds": [{ "type": "shadowsocks", "listen": "127.0.0.1", "listen_port": $SS,
"method": "2022-blake3-aes-128-gcm", "password": "$KEY" }],
"outbounds": [{ "type": "direct" }] }
EOF
sing-box run -c "$STATE/server.json" &
SERVER=$!
trap 'kill $SERVER ${SERVICE:-} 2>/dev/null || true' EXIT
# A configuration on the first run; after that, whatever the app made of it.
if [ ! -f "$STATE/config.json" ]; then
cat >"$STATE/config.json" <<EOF
{ "proxy": { "enable": true, "listener": { "port": $PROXY },
"singBox": { "clashApiPort": $CLASH, "testPort": $TEST },
"routing": { "directRu": false },
"outbounds": [{ "tag": "demo", "url": "ss://2022-blake3-aes-128-gcm:${KEY//=/%3D}@127.0.0.1:$SS#Demo" }] } }
EOF
fi
release=$(ls -d dist/ProxySuite-*-windows-x64/components/zapret 2>/dev/null | tail -1 || true)
if [ -n "$release" ] && [ ! -e "$STATE/bin/zapret" ]; then
mkdir -p "$STATE/bin" && cp -r "$release" "$STATE/bin/zapret"
fi
cargo build -q -p ps-service
target/debug/proxy-suite-service --console --state-dir "$STATE" --socket "$SOCK" &
SERVICE=$!
echo "the service: $SOCK (state in $STATE)"
wait $SERVICE