zeus
3 years ago
1 changed files with 15 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||||
|
function EPHEMERAL_PORT() { |
||||
|
LOW_BOUND=49152 |
||||
|
RANGE=16384 |
||||
|
while true; do |
||||
|
CANDIDATE=$[$LOW_BOUND + ($RANDOM % $RANGE)] |
||||
|
(echo "" >/dev/tcp/127.0.0.1/${CANDIDATE}) >/dev/null 2>&1 |
||||
|
if [ $? -ne 0 ]; then |
||||
|
echo $CANDIDATE |
||||
|
break |
||||
|
fi |
||||
|
done |
||||
|
} |
||||
|
|
||||
|
port=$(EPHEMERAL_PORT) |
||||
|
echo $port |
Loading…
Reference in new issue