summaryrefslogtreecommitdiffstats
path: root/ship/lib/retiolum
diff options
context:
space:
mode:
authormakefu <root@pigstarter.de>2014-04-29 16:31:51 +0200
committermakefu <root@pigstarter.de>2014-04-29 16:31:51 +0200
commitd14d0ae3e34a49b742c5d5e9b879e92c704edaa1 (patch)
tree507decaa8b23914ac1aa5bf848c4b063a9ef93c2 /ship/lib/retiolum
parentda3ff667030c5316712bf2280f733a2a85fc7ba3 (diff)
parent95fbba75246cf1b5115bc5493d3119f9ea91221e (diff)
Merge branch 'master' of https://github.com/krebscode/painload
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