From f46851de1af7c044471523c40e0fe88579b8a997 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 20 Feb 2014 18:50:20 +0100 Subject: add proposal for find-supers this script may be used when bootstrapping new retiolum nodes --- ship/lib/retiolum | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 ship/lib/retiolum (limited to 'ship/lib/retiolum') diff --git a/ship/lib/retiolum b/ship/lib/retiolum new file mode 100644 index 00000000..015537bd --- /dev/null +++ b/ship/lib/retiolum @@ -0,0 +1,76 @@ +#!/bin/sh +# retiolum host functions +#@include core +netname=${netname:-retiolum} + + +check_free_v4(){ + myipv4=${1-10.243.0.-1} + v4num=${myipv4##*.} + printf "Retard check: " + if [ "$v4num" -gt 0 -a "$v4num" -lt "256" ]; + then + info "No retard detected\n" + cd /etc/tinc/$netname/hosts + info "Check if ip is still free: " + for i in `ls -1`; do + if grep -q -e $myipv4\$ $i ;then + warn "Host IP already taken by $i! " + return 1 + fi + done + info "Passed\n" + return 0 + else + error "you are made of stupid. bailing out\n" + return 1 + fi + cd - >/dev/null +} + +find_active_nodes(){ + # TODO this function currently only supports a single address for a host + cd /etc/tinc/retiolum/hosts + # posix grep does not support [[:space:]] + for name in ` + grep '^[ ]*Address[ ]*=' * | + cut -d: -f1 | sort | uniq + `; do + if eval "`sed -n ' + s/[ ]\+//g + s/^\(Address\|Port\)=\(.*\)/\1="\${\1+\$\1\n}\2"/p + ' $name`"; then + port=${Port-655} + for host in $Address; do + if nc -zw 2 $host $port 2>/dev/null; then + echo "$name [('$host', $port)]" + fi & + done + wait + fi & + done + wait + cd - >/dev/null +} +find_supernodes(){ + cd /etc/tinc/retiolum/hosts + for name in ` + grep '^[ ]*Address[ ]*=' * | + cut -d: -f1 | sort | uniq + `; do + if eval "`sed -n ' + s/[ ]\+//g + s/^\(Address\|Port\)=\(.*\)/\1="\${\1+\$\1\n}\2"/p + ' $name`"; then + port=${Port-655} + for host in $Address; do + if nc -zw 2 $host $port 2>/dev/null; then + echo "$name [('$host', $port)]" + fi & + done + wait + fi & + done + wait + cd - >/dev/null +} -- cgit v1.2.3 From 1046da40ddc283cdec9d3156ecd6a37117c083cf Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 21 Feb 2014 13:23:05 +0100 Subject: add //ship/src/refresh-supers this script updates the currently configured supernodes in /etc/tinc/retiolum/tinc.conf with 5 random working supernodes in the retiolum darknet. The tinc.conf file can be given via environment. the hosts should be up-to-date in order to find all available supernodes. --- ship/lib/retiolum | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ship/lib/retiolum') diff --git a/ship/lib/retiolum b/ship/lib/retiolum index 015537bd..2a5c7338 100644 --- a/ship/lib/retiolum +++ b/ship/lib/retiolum @@ -1,8 +1,9 @@ #!/bin/sh # retiolum host functions #@include core +tinc_path=${tinc_path:-/etc/tinc} netname=${netname:-retiolum} - +hosts_dir=${hosts_dir:-$tinc_path/$netname/hosts} check_free_v4(){ myipv4=${1-10.243.0.-1} @@ -11,7 +12,7 @@ check_free_v4(){ if [ "$v4num" -gt 0 -a "$v4num" -lt "256" ]; then info "No retard detected\n" - cd /etc/tinc/$netname/hosts + cd $hosts_dir info "Check if ip is still free: " for i in `ls -1`; do if grep -q -e $myipv4\$ $i ;then @@ -30,8 +31,9 @@ check_free_v4(){ find_active_nodes(){ # TODO this function currently only supports a single address for a host - cd /etc/tinc/retiolum/hosts + cd $hosts_dir # posix grep does not support [[:space:]] + set +f for name in ` grep '^[ ]*Address[ ]*=' * | cut -d: -f1 | sort | uniq @@ -53,7 +55,8 @@ find_active_nodes(){ cd - >/dev/null } find_supernodes(){ - cd /etc/tinc/retiolum/hosts + cd $hosts_dir + set +f for name in ` grep '^[ ]*Address[ ]*=' * | cut -d: -f1 | sort | uniq -- cgit v1.2.3 From be4d573b21895449e57a8263a5a9ca292500a74b Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 26 Feb 2014 17:04:54 +0100 Subject: sort //ship/lib/retiolum --- ship/lib/retiolum | 56 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'ship/lib/retiolum') diff --git a/ship/lib/retiolum b/ship/lib/retiolum index 2a5c7338..3956a200 100644 --- a/ship/lib/retiolum +++ b/ship/lib/retiolum @@ -5,34 +5,9 @@ tinc_path=${tinc_path:-/etc/tinc} netname=${netname:-retiolum} hosts_dir=${hosts_dir:-$tinc_path/$netname/hosts} -check_free_v4(){ - myipv4=${1-10.243.0.-1} - v4num=${myipv4##*.} - printf "Retard check: " - if [ "$v4num" -gt 0 -a "$v4num" -lt "256" ]; - then - info "No retard detected\n" - cd $hosts_dir - info "Check if ip is still free: " - for i in `ls -1`; do - if grep -q -e $myipv4\$ $i ;then - warn "Host IP already taken by $i! " - return 1 - fi - done - info "Passed\n" - return 0 - else - error "you are made of stupid. bailing out\n" - return 1 - fi - cd - >/dev/null -} -find_active_nodes(){ - # TODO this function currently only supports a single address for a host +find_supernodes(){ cd $hosts_dir - # posix grep does not support [[:space:]] set +f for name in ` grep '^[ ]*Address[ ]*=' * | @@ -54,8 +29,11 @@ find_active_nodes(){ wait cd - >/dev/null } -find_supernodes(){ + +find_active_nodes(){ + # TODO this function currently only supports a single address for a host cd $hosts_dir + # posix grep does not support [[:space:]] set +f for name in ` grep '^[ ]*Address[ ]*=' * | @@ -77,3 +55,27 @@ find_supernodes(){ wait cd - >/dev/null } + +check_free_v4(){ + myipv4=${1-10.243.0.-1} + v4num=${myipv4##*.} + printf "Retard check: " + if [ "$v4num" -gt 0 -a "$v4num" -lt "256" ]; + then + info "No retard detected\n" + cd $hosts_dir + info "Check if ip is still free: " + for i in `ls -1`; do + if grep -q -e $myipv4\$ $i ;then + warn "Host IP already taken by $i! " + return 1 + fi + done + info "Passed\n" + return 0 + else + error "you are made of stupid. bailing out\n" + return 1 + fi + cd - >/dev/null +} -- cgit v1.2.3 From d818d26256380d1be91cb3d449271da96adb2105 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 26 Feb 2014 22:53:35 +0100 Subject: implement IRC proposal to refresh supernodes //ship/src/refresh-supers is the script which will update your tinc config and choose 5 working supernodes for you to connect to. This proposal may become part of the tinc.krebsco.de install script --- ship/lib/retiolum | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'ship/lib/retiolum') diff --git a/ship/lib/retiolum b/ship/lib/retiolum index 3956a200..1e55041c 100644 --- a/ship/lib/retiolum +++ b/ship/lib/retiolum @@ -1,10 +1,28 @@ #!/bin/sh # retiolum host functions #@include core +#@include network tinc_path=${tinc_path:-/etc/tinc} netname=${netname:-retiolum} hosts_dir=${hosts_dir:-$tinc_path/$netname/hosts} +supernode_urls="http://euer.krebsco.de/retiolum/supernodes.tar.gz" +reload_tinc(){ + info "reloading tinc configuration" + pkill -HUP tincd || tinc -n $netname reload; +} +refresh_supernode_keys(){ + for url in $supernode_urls;do + info "Trying $url to retrieve supernodes" + if http_get "$url" \ + | tar xvz -C $hosts_dir | xargs -n1 echo "refreshed:" ;then + info "refreshed supernode keys" + return 0 + else + error "$url unusable for retrieving supernode host files" + fi + done && return 1 +} find_supernodes(){ cd $hosts_dir @@ -67,7 +85,7 @@ check_free_v4(){ info "Check if ip is still free: " for i in `ls -1`; do if grep -q -e $myipv4\$ $i ;then - warn "Host IP already taken by $i! " + error "Host IP already taken by $i! " return 1 fi done -- cgit v1.2.3 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