summaryrefslogtreecommitdiffstats
path: root/ship/lib/retiolum
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2014-04-27 18:18:08 +0200
committermakefu <github@syntax-fehler.de>2014-04-27 18:18:08 +0200
commit95fbba75246cf1b5115bc5493d3119f9ea91221e (patch)
treecca50d644839abdf40947d47b9f75220e5d78f63 /ship/lib/retiolum
parentaa4b1772353ddf520b210bb1a692ce1b604cba23 (diff)
update things
Diffstat (limited to 'ship/lib/retiolum')
-rw-r--r--ship/lib/retiolum16
1 files changed, 13 insertions, 3 deletions
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