syncthing: improve relay argument parsing
authorGeorge Sapkin <[email protected]>
Wed, 6 Aug 2025 20:11:34 +0000 (23:11 +0300)
committerHannu Nyman <[email protected]>
Sun, 24 Aug 2025 16:43:57 +0000 (19:43 +0300)
Fixes: 47644ba46 ("syncthing: fix discovery and relay extra args")
Signed-off-by: George Sapkin <[email protected]>
utils/syncthing/Makefile
utils/syncthing/files/strelaysrv.conf
utils/syncthing/files/strelaysrv.init

index a71704cb939e46a84009bba1f9d1b86ad951272d..08703e0fc7bf641dc156253a1bc74dec8aa23a40 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=syncthing
 PKG_VERSION:=1.30.0
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=syncthing-source-v$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/syncthing/syncthing/releases/download/v$(PKG_VERSION)
index b69fb824ff638e9a1d159af458661063499124c2..7c33a30ec4442e86f44fb54ab4bb6f076a904a36 100644 (file)
@@ -20,8 +20,10 @@ config strelaysrv 'strelaysrv'
        # option status_srv ':22070'
        # option token ''
 
-       # CLI options with no value should be defined as booleans and theirs names
-       # should be prefixed with '_'.
-       # option _debug '0'
-       # option _nat '0'
-       # option _pprof '0'
+       # Running as 'root' is possible, but not recommended
+       # option user 'syncthing'
+
+       # CLI options with no value should be defined as booleans
+       # option debug '0'
+       # option nat '0'
+       # option pprof '0'
index f7fe4b95308652e3dbf6b7625a3e9a73019ea2ae..bdd472ba40ec3cc1b08804784f0fca0b5dc3f18c 100644 (file)
@@ -13,39 +13,44 @@ config_cb() {
        option_cb() {
                local option="$1"
                local value="$2"
-               case $option in
-               enabled|keys|pools|status_srv)
-                       eval $option=$value
-                       ;;
-               _*)
-                       [ "$value" = "0" ] || extra_args="$extra_args ${option//_/-}"
-                       ;;
-               *)
-                       extra_args="$extra_args -${option//_/-}='$value'"
-                       ;;
-               esac
-       }
-
-       list_cb() {
-               local name="$1"
-               local value="$2"
-               [ "$name" = "_" ] && extra_args="$extra_args -${value//_/-}" || return 0
+               # Remove the leading underscore from the option name for backward
+               # compatibility
+               option="${option#_}"
+               eval $option="$value"
        }
 }
 
 service_triggers() {
-       procd_add_reload_trigger "strelaysrv"
+       procd_add_reload_trigger 'strelaysrv'
 }
 
 start_service() {
-       local pools status_srv extra_args
-       # Options with default value different with the syncthing should be defined explicitly here
+       # Options with default value different with the syncthing should be defined
+       # explicitly here
        local enabled=0
-       local keys="/etc/strelaysrv"
+       local debug=0
+       local ext_address=''
+       local global_rate=''
+       local keys='/etc/strelaysrv'
+       local listen=':22067'
+       local message_timeout=''
+       local nat=0
+       local nat_lease=''
+       local nat_renewal=''
+       local nat_timeout=''
+       local network_timeout=''
        local nice=0
-       local user="syncthing"
-
-       config_load "strelaysrv"
+       local per_session_rate=''
+       local ping_interval=''
+       local pools=''
+       local pprof=0
+       local protocol=''
+       local provided_by=''
+       local status_srv=''
+       local token=''
+       local user='syncthing'
+
+       config_load 'strelaysrv'
 
        [ "$enabled" -gt 0 ] || return 0
 
@@ -58,16 +63,32 @@ start_service() {
 
        procd_open_instance
        procd_set_param command "$PROG"
+       [ "$debug" -eq 0 ] || procd_append_param command -debug
+       [ -z "$ext_address" ] || procd_append_param command -ext-address="$ext_address"
+       [ -z "$global_rate" ] || procd_append_param command -global-rate="$global_rate"
        procd_append_param command -keys="$keys"
-
-       # pools and status-srv are set to empty value by default
+       [ -z "$listen" ] || procd_append_param command -listen="$listen"
+       [ -z "$message_timeout" ] || procd_append_param command -message-timeout="$message_timeout"
+       [ "$nat" -eq 0 ] || procd_append_param command -nat
+       [ -z "$nat_lease" ] || procd_append_param command -nat-lease="$nat_lease"
+       [ -z "$nat_renewal" ] || procd_append_param command -nat-renewal="$nat_renewal"
+       [ -z "$nat_timeout" ] || procd_append_param command -nat-timeout="$nat_timeout"
+       [ -z "$network_timeout" ] || procd_append_param command -network-timeout="$network_timeout"
+       [ -z "$per_session_rate" ] || procd_append_param command -per-session-rate="$per_session_rate"
+       [ -z "$ping_interval" ] || procd_append_param command -ping-interval="$ping_interval"
+       # pools is set to an empty value by default
        procd_append_param command -pools="$pools"
+       [ "$pprof" -eq 0 ] || procd_append_param command -pprof
+       [ -z "$protocol" ] || procd_append_param command -protocol="$protocol"
+       [ -z "$provided_by" ] || procd_append_param command -provided-by="$provided_by"
+       # status-srv is set to an empty value by default
        procd_append_param command -status-srv="$status_srv"
-       [ -z "$extra_args" ] || procd_append_param command $extra_args
+       [ -z "$token" ] || procd_append_param command -token="$token"
 
        procd_set_param nice "$nice"
        procd_set_param term_timeout 15
        procd_set_param user "$user"
+       procd_set_param group "$group"
        procd_set_param respawn
        procd_set_param stdout 1
        procd_set_param stderr 1