From 6cd060681ef57f29cb9047fa3e18e330c4e7f9e0 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Mon, 24 Jul 2023 12:24:40 +0300 Subject: [PATCH] Allow only one session per ip --- executor.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/executor.sh b/executor.sh index bc56401..6e1bdaf 100755 --- a/executor.sh +++ b/executor.sh @@ -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