feat/wip/fix: add inbounds support, fix ssh-proxy

This commit is contained in:
fufsob committed 2026-09-09 16:38:52 +00:00
1 parent ea7916dffb
commit 2a319d1f88
39 files changed
+5093 -48

No files matched your search

+78
View File
@@ -2,6 +2,8 @@ ALL_SERVICES=(
proxy-suite-socks
proxy-suite-tproxy
proxy-suite-tun
proxy-suite-inbounds
proxy-suite-ssh-proxy
proxy-suite-tg-ws-proxy
proxy-suite-zapret-vm-exempt
zapret-discord-youtube
@@ -49,6 +51,7 @@ _usage() {
echo " proxy on|off enable/disable the proxy backend stack"
echo " tproxy on|off enable/disable TProxy transparent mode"
echo " tun on|off enable/disable TUN mode"
echo " ssh on|off enable/disable the SSH SOCKS5 proxy"
echo " awg list|status [profile] list profiles or show AmneziaWG status"
echo " awg on <profile> start an AmneziaWG profile"
echo " awg off [profile] stop one or all active AmneziaWG profiles"
@@ -64,6 +67,9 @@ _usage() {
echo " wrap <profile> -- <cmd> run a command via a perAppRouting profile"
echo " subscription list show subscriptions, cache age, and proxy count"
echo " subscription update force-refresh all subscription caches and restart active proxy services"
echo " inbounds [list] list server inbounds and their state"
echo " inbounds link <tag> [user] print the client share link for an inbound"
echo " inbounds qr <tag> [user] print the client share link as a QR code"
exit "$status"
}
@@ -363,6 +369,8 @@ cmd_route_mode() {
RESTART_SERVICES=(
proxy-suite-tproxy
proxy-suite-tun
proxy-suite-inbounds
proxy-suite-ssh-proxy
proxy-suite-tg-ws-proxy
zapret-discord-youtube
)
@@ -601,3 +609,73 @@ cmd_subscription() {
;;
esac
}
_ensure_inbounds() {
if [ "${INBOUNDS_ENABLED:-0}" != "1" ]; then
echo "proxyInbounds is not enabled in services.proxy-suite.proxyInbounds."
exit 1
fi
}
# Links carry listener credentials, so the file is root/group-only. Say so
# rather than leaking a bare permission error.
_inbound_links() {
if [ ! -f "$INBOUNDS_LINKS_FILE" ]; then
echo "No share links available. Is proxy-suite-inbounds running, and is proxyInbounds.shareLinks enabled?" >&2
exit 1
fi
if [ ! -r "$INBOUNDS_LINKS_FILE" ]; then
echo "Share links are not readable by this user. Enable userControl, or run as root." >&2
exit 1
fi
cat "$INBOUNDS_LINKS_FILE"
}
_inbound_link_for() {
local tag="$1" user="${2:-}" matches count
matches="$(_inbound_links | jq -c --arg tag "$tag" --arg user "$user" '[.[] | select(.tag == $tag) | select($user == "" or .user == $user)]')"
count="$(jq 'length' <<< "$matches")"
if [ "$count" -eq 0 ]; then
echo "Unknown inbound, or no share link for it: $tag" >&2
exit 1
fi
if [ "$count" -ne 1 ]; then
echo "Multiple users match '$tag'; specify one of:" >&2
jq -r '.[].user' <<< "$matches" | sed 's/^/ /' >&2
exit 1
fi
jq -r '.[0].link' <<< "$matches"
}
cmd_inbounds() {
_ensure_inbounds
case "${1:-list}" in
list)
echo "proxy-suite inbounds:"
printf " %-24s %-16s %-14s %-8s %s\n" TAG USER TYPE PORT STATE
local state
state="$(systemctl is-active proxy-suite-inbounds 2>/dev/null || true)"
_inbound_links \
| jq -r --arg state "$state" '.[] | "\(.tag)\t\(.user)\t\(.type)\t\(.port)\t\($state)"' \
| awk -F'\t' '{printf " %-24s %-16s %-14s %-8s %s\n", $1, $2, $3, $4, $5}'
;;
link)
if [ -z "${2:-}" ]; then
echo "Usage: proxy-ctl inbounds link <tag> [user]" >&2
exit 1
fi
_inbound_link_for "$2" "${3:-}"
;;
qr)
if [ -z "${2:-}" ]; then
echo "Usage: proxy-ctl inbounds qr <tag> [user]" >&2
exit 1
fi
_inbound_link_for "$2" "${3:-}" | qrencode -t ANSIUTF8
;;
*)
echo "Usage: proxy-ctl inbounds [list|link <tag> [user]|qr <tag> [user]]" >&2
exit 1
;;
esac
}
+8 -1
View File
@@ -19,6 +19,8 @@
routeModeStateFile,
defaultRouteMode,
amneziaWgProfileNamesFile,
inboundsEnabled,
inboundsLinksFile,
}:
let
@@ -41,6 +43,8 @@ let
ROUTE_MODE_STATE_FILE = routeModeStateFile;
DEFAULT_ROUTE_MODE = defaultRouteMode;
AWG_PROFILES_FILE = toString amneziaWgProfileNamesFile;
INBOUNDS_ENABLED = inboundsEnabled;
INBOUNDS_LINKS_FILE = inboundsLinksFile;
};
in
pkgs.symlinkJoin {
@@ -67,6 +71,7 @@ pkgs.symlinkJoin {
pkgs.gnugrep
pkgs.jq
pkgs.proxychains-ng
pkgs.qrencode
pkgs.systemd
]
}" \
@@ -84,6 +89,8 @@ pkgs.symlinkJoin {
--set PROXYCHAINS_QUIET_ARG ${lib.escapeShellArg (lib.removeSuffix " " proxychainsQuietArg)} \
--set ROUTE_MODE_STATE_FILE ${lib.escapeShellArg routeModeStateFile} \
--set DEFAULT_ROUTE_MODE ${lib.escapeShellArg defaultRouteMode} \
--set AWG_PROFILES_FILE ${lib.escapeShellArg (toString amneziaWgProfileNamesFile)}
--set AWG_PROFILES_FILE ${lib.escapeShellArg (toString amneziaWgProfileNamesFile)} \
--set INBOUNDS_ENABLED ${lib.escapeShellArg inboundsEnabled} \
--set INBOUNDS_LINKS_FILE ${lib.escapeShellArg inboundsLinksFile}
'';
}
+8
View File
@@ -39,6 +39,10 @@ case "$cmd" in
cmd_mode_toggle proxy-suite-tun on "${1:-}"
;;
ssh)
cmd_mode_toggle proxy-suite-ssh-proxy on "${1:-}" ssh
;;
awg)
cmd_awg "$@"
;;
@@ -77,6 +81,10 @@ case "$cmd" in
cmd_wrap "$@"
;;
inbounds)
cmd_inbounds "$@"
;;
subscription)
cmd_subscription "$@"
;;