From bcf33de7e12eada7f397bab5cab39a1bd90526ad Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Mon, 24 Jul 2023 01:11:02 +0300 Subject: [PATCH] random port selection --- README.md | 2 +- bbs.sh | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2c99cb4..a2d0940 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,4 @@ $EDITOR config ```run server (socat required) ./bss.sh ``` - +run it without argument -> random port selected diff --git a/bbs.sh b/bbs.sh index d64fbc4..1168924 100755 --- a/bbs.sh +++ b/bbs.sh @@ -1,7 +1,13 @@ #!/bin/sh -echo "listening for commands on 0.0.0.0:$1" +if [ ! -n "$1" ]; then + port=$(shuf -i 1024-65000 -n 1) +else + port=$1 +fi -socat -v -v TCP-LISTEN:$1,reuseaddr,pktinfo,fork SYSTEM:"./executor.sh" +echo "listening for commands on 0.0.0.0:$port" + +socat -v -v TCP-LISTEN:$port,reuseaddr,pktinfo,fork SYSTEM:"./executor.sh"