netplay speed up

This commit is contained in:
Dragoon Dorise 2024-04-15 14:44:23 +02:00
parent e5c9b481ec
commit 4da3653fb6

View file

@ -7,6 +7,7 @@
# netplayCMD - local inet
#Searchs for a device with the netplay port open
netplaySetIP(){
localIP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
segment=$(echo $localIP | awk -F '.' '{print $1"."$2"."$3}')
@ -15,9 +16,10 @@ netplaySetIP(){
for i in {2..255}; do
{
ip="$subnet$i"
if (echo > /dev/tcp/$ip/$port) >/dev/null 2>&1; then
echo $ip
if timeout 0.05 bash -c "echo > /dev/tcp/$ip/$port"; then
setSetting netplayCMD "'-C $ip'"
exit
break
fi
} &
done