removed "cat -" pipe, it works fine as is

This commit is contained in:
localhost_frssoft 2023-07-22 22:42:54 +03:00
parent 83194c4083
commit 0412550d45

View File

@ -26,43 +26,43 @@ mkdir -p -m 700 access_granted
generator_session=$(zcat -f $system_dict | shuf -n 2 | tr -d "\n'") generator_session=$(zcat -f $system_dict | shuf -n 2 | tr -d "\n'")
randpadding=$(head -c 8 /dev/urandom | base64) randpadding=$(head -c 8 /dev/urandom | base64)
printf "$randpadding\t$generator_session\n" printf "$randpadding\t$generator_session\n"
cat - |
while read -r cmd mesg; do while read -r cmd mesg; do
if [ "$cmd" = "reg" ]; then if [ "$cmd" = "reg" ]; then
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" touch access_granted/"$remote_ip"
echo hi $remote_ip echo hi $remote_ip
else else
die
break
fi
fi
if [ ! -f access_granted/"$remote_ip" ]; then # Drop unregistred handshake
die die
break break
fi fi
# --- fi
case $cmd in if [ ! -f access_granted/"$remote_ip" ]; then # Drop unregistred handshake
"post") toot "$mesg" | jq '.id, .errors' ;; die
"reply") break
reply_id=$(echo "$mesg" | cut -d' ' -f 1) fi
status=$(echo "$mesg" | cut -d' ' -f 2-) # ---
reply=$reply_id toot "$status" | jq '.id, .errors' case $cmd in
reply='' "post") toot "$mesg" | jq '.id, .errors' ;;
;; "reply")
"home") timeline_home "$mesg" ;; reply_id=$(echo "$mesg" | cut -d' ' -f 1)
"reg") printf 'bbs > '; continue ;; status=$(echo "$mesg" | cut -d' ' -f 2-)
"x") reply=$reply_id toot "$status" | jq '.id, .errors'
case $mesg in reply=''
"http"*) w3m -dump -T text/html -cols 34 -o 'display_link_number=1' "$mesg" ;; ;;
*) echo 'only http(s)' ;; "home") timeline_home "$mesg" ;;
esac "reg") printf 'bbs > '; continue ;;
;; "x")
*) die; break ;; case $mesg in
esac "http"*) w3m -dump -T text/html -cols 34 -o 'display_link_number=1' "$mesg" ;;
printf 'bbs > ' *) echo 'only http(s)' ;;
done esac
;;
*) die; break ;;
esac
printf 'bbs > '
done
rm access_granted/"$remote_ip" rm access_granted/"$remote_ip"
echo 'session was close' echo 'session was close'