new_version

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-19 11:09:13 +02:00
1 parent 910bb563f0
commit a946c38194
32 files changed
+809 -65

No files matched your search

View File
File mode changed.
View File
File mode changed.
+37 -1
View File
@@ -18,6 +18,8 @@ load_rc_config "$name"
: ${rustproxy_user:="root"}
: ${rustproxy_group:="wheel"}
: ${rustproxy_data_dir:="/var/db/rustproxy"}
# Optional external canonical JSON (absolute path without spaces).
: ${rustproxy_config_path:=""}
: ${rustproxy_log_dir:="/var/log/rustproxy"}
: ${rustproxy_log_file:="${rustproxy_log_dir}/rustproxy.log"}
: ${rustproxy_run_dir:="/var/run/rustproxy"}
@@ -163,7 +165,20 @@ if ! rustproxy_valid_update_interval "$rustproxy_update_check_interval_secs"; th
exit 1
fi
rustproxy_runtime_args="--data-dir ${rustproxy_data_dir} --admin-listen ${rustproxy_admin_listen_resolved} --update-check-interval-secs ${rustproxy_update_check_interval_secs} serve --proxy-listen ${rustproxy_proxy_listen_resolved}"
# Restrict to shell-safe absolute paths because rc.subr expands command_args.
rustproxy_config_arg=""
if [ -n "${rustproxy_config_path}" ]; then
case "${rustproxy_config_path}" in
/*) ;;
*) echo "rustproxy_config_path must be an absolute path" >&2; exit 1 ;;
esac
case "${rustproxy_config_path}" in
*[!a-zA-Z0-9_./-]*) echo "rustproxy_config_path contains unsupported characters" >&2; exit 1 ;;
esac
rustproxy_config_arg="--config ${rustproxy_config_path}"
fi
rustproxy_runtime_args="--data-dir ${rustproxy_data_dir} ${rustproxy_config_arg} --admin-listen ${rustproxy_admin_listen_resolved} --update-check-interval-secs ${rustproxy_update_check_interval_secs} serve --proxy-listen ${rustproxy_proxy_listen_resolved}"
if [ "$rustproxy_tls_enabled" = "1" ]; then
rustproxy_runtime_args="${rustproxy_runtime_args} --tls-listen ${rustproxy_tls_listen_resolved}"
fi
@@ -186,6 +201,8 @@ start_precmd="rustproxy_prestart"
start_postcmd="rustproxy_poststart"
stop_postcmd="rustproxy_poststop"
status_cmd="rustproxy_status"
extra_commands="reload"
reload_cmd="rustproxy_reload"
rustproxy_prestart()
{
@@ -286,6 +303,25 @@ rustproxy_status()
return 1
}
rustproxy_reload()
{
# rust-proxy reload authenticates locally via SQLite; it must run as the
# same account as the daemon and address the listener through loopback.
rustproxy_child_pid >/dev/null || {
echo "RustProxy is not running; nothing to reload" >&2
return 1
}
_rp_port="${rustproxy_admin_listen_resolved##*:}"
case "${rustproxy_admin_listen_resolved}" in
\[*\]:*) _rp_local_admin="[::1]:${_rp_port}" ;;
*:*) _rp_local_admin="127.0.0.1:${_rp_port}" ;;
*) echo "Invalid RustProxy administration listen address" >&2; return 1 ;;
esac
# The optional path is already checked for safe characters above.
${rustproxy_command} --data-dir "${rustproxy_data_dir}" ${rustproxy_config_arg} \
--admin-listen "${_rp_local_admin}" reload
}
rustproxy_poststop()
{
/bin/rm -f "${child_pidfile}" "${pidfile}"
@@ -36,10 +36,19 @@ case "${1:-}" in
stop)
stop_service
;;
restart|reload)
restart)
stop_service
start_service
;;
reload)
if [ "$enabled" != "1" ]; then
echo "RustProxy is disabled in OPNsense configuration" >&2
exit 1
fi
# Soft reload is performed by rust-proxy CLI through the live admin API.
# Listener changes from the GUI still require the explicit restart action.
"$RC_SCRIPT" reload
;;
status)
"$RC_SCRIPT" status
;;
@@ -20,7 +20,7 @@ message:restarting RustProxy
allowed_groups:wheel,wwwonly
[reload]
command:/usr/local/opnsense/scripts/rustproxy/service.sh restart
command:/usr/local/opnsense/scripts/rustproxy/service.sh reload
parameters:
type:script
message:reloading RustProxy