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
die(){
rm access_granted/"$remote_ip"
echo 'bye'
pkill -P $PPID
}
@ -24,14 +23,14 @@ while read -r cmd mesg; do
key=$(echo "$mesg" | cut -d' ' -f 2)
session=$(echo "$mesg" | cut -d' ' -f 1)
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
else
die
break
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
break
fi
@ -76,7 +75,7 @@ while read -r cmd mesg; do
done
toot $full_status | jq '.id, .errors'
;;
*) die; break ;;
*) break ;;
esac
printf 'bbs > '
done