From 95fbba75246cf1b5115bc5493d3119f9ea91221e Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 27 Apr 2014 18:18:08 +0200 Subject: update things --- ship/lib/retiolum | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'ship/lib/retiolum') diff --git a/ship/lib/retiolum b/ship/lib/retiolum index 1e55041c..eba2775e 100644 --- a/ship/lib/retiolum +++ b/ship/lib/retiolum @@ -23,7 +23,17 @@ refresh_supernode_keys(){ fi done && return 1 } - +port_open(){ + # $1 - host + # $2 - port + # nc -zw 2 $1 $2 + echo | run_telnet "$1" "$2" & pid=$! + { sleep 5; kill $pid;} & wid=$! + wait $pid + RET=$? + kill $wid >/dev/null 2>&1 + return $RET +} find_supernodes(){ cd $hosts_dir set +f @@ -37,7 +47,7 @@ find_supernodes(){ ' $name`"; then port=${Port-655} for host in $Address; do - if nc -zw 2 $host $port 2>/dev/null; then + if port_open $host $port 2>/dev/null; then echo "$name [('$host', $port)]" fi & done @@ -63,7 +73,7 @@ find_active_nodes(){ ' $name`"; then port=${Port-655} for host in $Address; do - if nc -zw 2 $host $port 2>/dev/null; then + if port_open $host $port 2>/dev/null; then echo "$name [('$host', $port)]" fi & done -- cgit v1.2.3