Skip to content

Commit

Permalink
v9.9
Browse files Browse the repository at this point in the history
- DietPi-Software | frp: Fix parsing client input, allow any characters for the token (as we do not know any limitations), and make use of the native G_WHIP_INPUTBOX input validation. Also expose the server bind address in our default config, which might be more commonly changed to limit access to particular networks.
  • Loading branch information
MichaIng committed Dec 1, 2024
1 parent 49af19d commit 619aa32
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
Expand Up @@ -6526,10 +6526,10 @@ _EOF_
then
case $G_HW_ARCH in
1) local arch='arm';;
2) local arch='arm_hf';;
3) local arch='arm64';;
10) local arch='amd64';;
11) local arch='riscv64';;
*) local arch='arm_hf';;
*) local arch='riscv64';;
esac

# Download
Expand Down Expand Up @@ -6580,6 +6580,7 @@ _EOF_
# Pre-create config file to turn on dashboard
token=$(openssl rand -hex 15)
[[ -f '/etc/frp/frps.toml' ]] || cat << _EOF_ > /etc/frp/frps.toml
bindAddr = "0.0.0.0"
bindPort = 7000

webServer.addr = "0.0.0.0"
Expand Down Expand Up @@ -6616,33 +6617,18 @@ RestartSec=5s
[Install]
WantedBy=multi-user.target
_EOF_
local server_addr=127.0.0.1 server_port=7000
local server_addr='127.0.0.1' server_port=7000
if [[ $G_WHIP_RETURNED_VALUE == 'Client' ]]
then
local invalid_entry=
while :
do
if G_WHIP_INPUTBOX "${invalid_entry}Please enter the IP address of your frp server, including port (default 7000)" && [[ $G_WHIP_RETURNED_VALUE =~ ^[0-9.:]+$ ]]
then
server_addr=${G_WHIP_RETURNED_VALUE#*:}
[[ $G_WHIP_RETURNED_VALUE =~ : ]] && server_port=${G_WHIP_RETURNED_VALUE%:*}
invalid_entry=
break
else
invalid_entry='[FAILED] Please enter a valid IP address\n\n'
fi
done

while :
do
if G_WHIP_INPUTBOX "${invalid_entry}Please enter the authentication token of your frp server" && [[ $G_WHIP_RETURNED_VALUE =~ ^[0-9.]+$ ]]
then
token=$G_WHIP_RETURNED_VALUE
break
else
invalid_entry='[FAILED] Please enter a token\n\n'
fi
done
G_WHIP_DEFAULT_ITEM="$server_addr:$server_port"
G_WHIP_INPUTBOX_REGEX='^[0-9.:]+$'
G_WHIP_INPUTBOX_REGEX_TEXT='be a valid IP address, optionally with appended network port number, like "192.168.1.100:7000"'
G_WHIP_INPUTBOX 'Please enter the IP address of your frp server, optionally including port (default 7000):'
server_addr=${G_WHIP_RETURNED_VALUE%:*}
[[ $G_WHIP_RETURNED_VALUE =~ : ]] && server_port=${G_WHIP_RETURNED_VALUE##*:}

G_WHIP_INPUTBOX 'Please enter the authentication token of your frp server:'
token=$G_WHIP_RETURNED_VALUE
fi

# Pre-create config file to turn on admin UI
Expand Down

0 comments on commit 619aa32

Please sign in to comment.