tor-hs: tor-hs.init handle_hs_ports_conf split ports

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 <stokito@gmail.com>
This commit is contained in:
Sergey Ponomarev 2023-07-15 17:27:39 +03:00 committed by Josef Schlehofer
parent 910041d39f
commit c709e7a09f
1 changed files with 2 additions and 2 deletions

View File

@ -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
}