mirror of
https://github.com/quickemu-project/quickemu.git
synced 2024-09-20 00:02:03 +02:00
Make port scans non-blocking
This commit is contained in:
parent
4f0bbfc667
commit
e6823edde7
5
quickemu
5
quickemu
|
@ -136,8 +136,9 @@ function get_port() {
|
|||
local PORT_RANGE=$((PORT_START+$2))
|
||||
local PORT
|
||||
for ((PORT = PORT_START; PORT <= PORT_RANGE; PORT++)); do
|
||||
(echo -n "" >/dev/tcp/127.0.0.1/"${PORT}") >/dev/null 2>&1
|
||||
if [ ${?} -ne 0 ]; then
|
||||
# Make sure port scans do not block too long.
|
||||
timeout 0.1s bash -c "echo >/dev/tcp/127.0.0.1/${PORT}" >/dev/null 2>&1
|
||||
if [ ${?} -eq 1 ]; then
|
||||
echo "${PORT}"
|
||||
break
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue
Block a user