45780 45781 PORT SWAPING

This commit is contained in:
fred 2023-03-01 00:23:36 +01:00
parent 8865ab418d
commit d472f9682f
1 changed files with 5 additions and 4 deletions

View File

@ -65,10 +65,11 @@ while true; do
# EACH VISITOR RECEIVE COMMAND RESPONSE ON
## RANDOM PORT = RESPONSE SOCKET & IPNS SESSION TOKEN
[ ${PORT} -le 12345 ] && PORT=$((PORT+${RANDOM:0:2})) || PORT=$((PORT-${RANDOM:0:2}))
[[ ${isLAN} && $(which yunohost) ]] && PORT=$((PORT+1)) && [ ${PORT} -ge 45782 ] && PORT=45780 ## yunohost OPEN FIREWALL 1234 12345 45780 45781
## RANDOM PORT SWAPPINESS AVOIDING COLLISION
[[ ${isLAN} && $(which yunohost) ]]; then
PORT=$((PORT+1)) && [ ${PORT} -ge 45782 ] && PORT=45780 ## yunohost OPEN FIREWALL 1234 12345 45780 45781
else
[ ${PORT} -le 12345 ] && PORT=$((PORT+${RANDOM:0:2})) || PORT=$((PORT-${RANDOM:0:2}))
fi ## RANDOM PORT SWAPPINESS AVOIDING COLLISION
## CHECK PORT IS FREE & KILL OLD ONE
pidportinuse=$(ps axf --sort=+utime | grep -w "nc -l -p ${PORT}" | grep -v -E 'color=auto|grep' | awk '{gsub(/^ +| +$/,"")} {print $0}' | tail -n 1 | cut -d " " -f 1)