minor updates
This commit is contained in:
parent
e3790a4f3f
commit
628baf3eea
32 changed files with 655 additions and 123 deletions
|
|
@ -10,40 +10,40 @@ trap 'die' SIGTERM SIGQUIT SIGINT
|
|||
|
||||
declare -a CONFIGS
|
||||
for config in /etc/wireguard/*; do
|
||||
config="$(basename "$config")"
|
||||
CONFIGS+=("${config%.conf}")
|
||||
config="$(basename "$config")"
|
||||
CONFIGS+=("${config%.conf}")
|
||||
done
|
||||
|
||||
COMMANDS=("up" "down")
|
||||
|
||||
die() {
|
||||
rm $PIPE
|
||||
exit 0
|
||||
rm $PIPE
|
||||
exit 0
|
||||
}
|
||||
|
||||
in_arr() {
|
||||
declare -n arr="$2"
|
||||
declare -n arr="$2"
|
||||
|
||||
for value in "${arr[@]}"; do
|
||||
[ "$value" = "$1" ] && return 0
|
||||
done
|
||||
return 1
|
||||
for value in "${arr[@]}"; do
|
||||
[ "$value" = "$1" ] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
main() {
|
||||
mkfifo $PIPE -m666
|
||||
mkfifo $PIPE -m666
|
||||
|
||||
while :; do
|
||||
read -r cmd ifname < $PIPE
|
||||
while :; do
|
||||
read -r cmd ifname < $PIPE
|
||||
|
||||
if ! in_arr "$ifname" "CONFIGS"; then
|
||||
echo "ERROR: Invalid interface $ifname" > $PIPE
|
||||
elif ! in_arr "$cmd" "COMMANDS"; then
|
||||
echo "ERROR: Invalid command $cmd" > $PIPE
|
||||
else
|
||||
wg-quick "$cmd" "$ifname" > $PIPE 2>&1
|
||||
fi
|
||||
done
|
||||
if ! in_arr "$ifname" "CONFIGS"; then
|
||||
echo "ERROR: Invalid interface $ifname" > $PIPE
|
||||
elif ! in_arr "$cmd" "COMMANDS"; then
|
||||
echo "ERROR: Invalid command $cmd" > $PIPE
|
||||
else
|
||||
wg-quick "$cmd" "$ifname" > $PIPE 2>&1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
main
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue