tor-hs: tor-hs.init handle_hs_ports_conf split ports
authorSergey Ponomarev <redacted>
Sat, 15 Jul 2023 14:27:39 +0000 (17:27 +0300)
committerJosef Schlehofer <redacted>
Tue, 20 May 2025 11:20:46 +0000 (13:20 +0200)
Using substring instead of awk.
It changes behaviour when only one port is specified.
Previously:
value="80" => public="80" local=""
Now:
value="80" => public="80" local="80"

It simplifies configuration of one-to-one ports.

Signed-off-by: Sergey Ponomarev <redacted>
net/tor-hs/files/tor-hs.init

index 7486bb7fa792bb3bd6db89f729843c0857ac0944..28cbeca38342b0f2605224ec1a48294d67344f9a 100755 (executable)
@@ -43,8 +43,8 @@ handle_hs_ports_conf() {
        local value="$1"
        local ipv4="$2"
 
-       public_port=$(echo "$value"|awk -F';' '{print $1}')
-       local_port=$(echo "$value"|awk -F';' '{print $2}')
+       public_port="${value#*;}"
+       local_port="${value%;*}"
        echo "HiddenServicePort $public_port $ipv4:$local_port">>$TORRC_FILE
 }
 
git clone https://git.99rst.org/PROJECT