Allow only one session per ip

This commit is contained in:
localhost_frssoft 2023-07-24 12:24:40 +03:00
parent 41bbe69ac1
commit 6cd060681e

View File

@ -4,7 +4,6 @@
remote_ip=$SOCAT_PEERADDR remote_ip=$SOCAT_PEERADDR
die(){ die(){
rm access_granted/"$remote_ip"
echo 'bye' echo 'bye'
pkill -P $PPID pkill -P $PPID
} }
@ -24,14 +23,14 @@ while read -r cmd mesg; do
key=$(echo "$mesg" | cut -d' ' -f 2) key=$(echo "$mesg" | cut -d' ' -f 2)
session=$(echo "$mesg" | cut -d' ' -f 1) session=$(echo "$mesg" | cut -d' ' -f 1)
if [ "$session" = "$generator_session" ] && [ "$key" = "$pass_for_bbs" ]; then if [ "$session" = "$generator_session" ] && [ "$key" = "$pass_for_bbs" ]; then
touch access_granted/"$remote_ip" echo "$generator_session" > access_granted/"$remote_ip"
echo hi $remote_ip echo hi $remote_ip
else else
die die
break break
fi fi
fi fi
if [ ! -f access_granted/"$remote_ip" ]; then # Drop unregistred handshake if [ ! -n "$(grep -F "$generator_session" access_granted/"$remote_ip")" ]; then # Drop unregistred handshake
die die
break break
fi fi
@ -76,7 +75,7 @@ while read -r cmd mesg; do
done done
toot $full_status | jq '.id, .errors' toot $full_status | jq '.id, .errors'
;; ;;
*) die; break ;; *) break ;;
esac esac
printf 'bbs > ' printf 'bbs > '
done done