diff --git a/src/packages/fff/fff-vpn-select/Makefile b/src/packages/fff/fff-vpn-select/Makefile index 267ed447..55825555 100644 --- a/src/packages/fff/fff-vpn-select/Makefile +++ b/src/packages/fff/fff-vpn-select/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fff-vpn-select -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select b/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select index b3efc6b8..30883f50 100755 --- a/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select +++ b/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select @@ -7,34 +7,36 @@ hoodfile="$1" make_config() { -# remove old config -rm /tmp/fastd_fff_peers/* -Index=1 -json_load "$(cat "$hoodfile")" -json_select vpn -# get fastd peers -while json_select "$Index" > /dev/null -do - json_get_var protocol protocol - if [ "$protocol" = "fastd" ]; then - json_get_var servername name - filename="/etc/fastd/fff/peers/$servername" - echo "#name \"${servername}\";" > "$filename" - json_get_var key key - echo "key \"${key}\";" >> "$filename" - json_get_var address address - json_get_var port port - echo "remote \"${address}\" port ${port};" >> "$filename" - echo "" >> "$filename" - echo "float yes;" >> "$filename" - fi - json_select ".." # back to vpn - Index=$(( Index + 1 )) -done -json_select ".." # back to root -} + # remove old config + rm /tmp/fastd_fff_peers/* -# main + # prepare + Index=1 + json_load "$(cat "$hoodfile")" + json_select vpn + + # get fastd peers + while json_select "$Index" > /dev/null + do + json_get_var protocol protocol + if [ "$protocol" = "fastd" ]; then + # set up fastd + json_get_var servername name + filename="/etc/fastd/fff/peers/$servername" + echo "#name \"${servername}\";" > "$filename" + json_get_var key key + echo "key \"${key}\";" >> "$filename" + json_get_var address address + json_get_var port port + echo "remote \"${address}\" port ${port};" >> "$filename" + echo "" >> "$filename" + echo "float yes;" >> "$filename" + fi + json_select ".." # back to vpn + Index=$(( Index + 1 )) + done + json_select ".." # back to root +} # Only do something if file is there and not empty; otherwise exit 1 if [ -s "$hoodfile" ]; then