mirror of
https://github.com/ben-grande/qusal.git
synced 2025-02-14 06:01:24 -05:00
![Ben Grande](/assets/img/avatar_default.png)
Echo can interpret operand as an option and checking every variable to be echoed is troublesome while with printf, if the format specifier is present before the operand, printing as string can be enforced.
39 lines
1.2 KiB
Bash
Executable File
39 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
|
##
|
|
## SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
## How to use with SSH?
|
|
## On Dom0 Qrexec policy:
|
|
## qusal.ConnectTCP +domain.tld+22 client @default ask default_target=proxy
|
|
## On Dom0, enable the "qusal-proxy-client" service for the client qube:
|
|
## qvm-features client service.qusal-proxy-client 1
|
|
## On the SSH Proxy server (netvm of your liking), install this RPC service.
|
|
## qubesctl --skip-dom0 --targets=proxy state.apply sys-net.install-proxy
|
|
## On the client ssh configuration:
|
|
## Match Exec "test -f /var/run/qubes-service/qusal-proxy-client"
|
|
## ProxyCommand qrexec-client-vm @default qusal.ConnectTCP+%h+%p
|
|
|
|
set -eu
|
|
|
|
# shellcheck disable=SC2154
|
|
arg="${QREXEC_SERVICE_ARGUMENT}"
|
|
host="${arg%%+*}"
|
|
port="${arg##*+}"
|
|
|
|
if test -z "${port}" || test -z "${host}" || test "${port}" = "${host}"; then
|
|
printf '%s\n' "Missing either host, port or both" >&2
|
|
exit 1
|
|
fi
|
|
if test "${#host}" -gt 256; then
|
|
printf '%s\n' "Host size exceeds limit" >&2
|
|
exit 1
|
|
fi
|
|
if test "${#port}" -gt 5 || test "${port}" -gt 65535; then
|
|
printf '%s\n' "Invalid port number, it must be between 1 and 65535" >&2
|
|
exit 1
|
|
fi
|
|
|
|
exec socat STDIO "TCP:${host}:${port}"
|