From abd83a5b91c00390300de40b8ada651212efe9a6 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 14 Jan 2013 15:14:46 +0100 Subject: retiolum find_super: parallel lookup --- retiolum/scripts/adv_graphgen/find_super | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) mode change 100644 => 100755 retiolum/scripts/adv_graphgen/find_super (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/adv_graphgen/find_super b/retiolum/scripts/adv_graphgen/find_super old mode 100644 new mode 100755 index c89a94fb..e971e204 --- a/retiolum/scripts/adv_graphgen/find_super +++ b/retiolum/scripts/adv_graphgen/find_super @@ -1,14 +1,25 @@ -#!/bin/sh -cd /etc/tinc/retiolum/hosts -ls -1 . | while read fname; -do - for i in `sed -n 's/Address\s*=\s*\(.*\)/\1/p' $fname`;do - if nc -zw 5 $i 655 2>/dev/null; then - echo "$fname - $i reachable" - #else - #echo -n - #echo "$fname - $i unreachable" +#! /bin/dash +set -euf +case "${1-all}" in + (all) + find /etc/tinc/retiolum/hosts -type f | + xargs -P 423 -n 1 "$0" one + ;; + (one) + hosts_file=$2 + name=$(basename $hosts_file) - fi - done -done + if grep -q Address $hosts_file; then + script="$(sed -n ' + s/[[:space:]]*//g + s/^\(Address\|Port\)=\(.*\)/\1="${\1+$\1 }\2"/p + ' $hosts_file)" + eval "$script" + for address in ${Address-}; do + if nc -zw 2 $address 655 2>/dev/null; then + echo $name - $address reachable + fi & + done + wait + fi +esac -- cgit v1.2.3 From 3b6a2e967d075145613faffa63ea9399fb6f1800 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 14 Jan 2013 16:05:20 +0100 Subject: retiolum find_super: replace xargs with for&wait --- retiolum/scripts/adv_graphgen/find_super | 44 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/adv_graphgen/find_super b/retiolum/scripts/adv_graphgen/find_super index e971e204..17a0c8c0 100755 --- a/retiolum/scripts/adv_graphgen/find_super +++ b/retiolum/scripts/adv_graphgen/find_super @@ -1,25 +1,21 @@ #! /bin/dash -set -euf -case "${1-all}" in - (all) - find /etc/tinc/retiolum/hosts -type f | - xargs -P 423 -n 1 "$0" one - ;; - (one) - hosts_file=$2 - name=$(basename $hosts_file) - - if grep -q Address $hosts_file; then - script="$(sed -n ' - s/[[:space:]]*//g - s/^\(Address\|Port\)=\(.*\)/\1="${\1+$\1 }\2"/p - ' $hosts_file)" - eval "$script" - for address in ${Address-}; do - if nc -zw 2 $address 655 2>/dev/null; then - echo $name - $address reachable - fi & - done - wait - fi -esac +set -eu +cd /etc/tinc/retiolum/hosts +for name in ` + grep '^[[:space:]]*Address[[:space:]]*=' * | + cut -d: -f1 | sort | uniq +`; do + if eval "`sed -n ' + s/[[:space:]]\+//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 reachable + fi & + done + wait + fi & +done +wait -- cgit v1.2.3 From bce6236eb787c047cfee496640533676d6dfeb45 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 14 Jan 2013 16:06:08 +0100 Subject: retiolum find_super: use same output format as find_super.py --- retiolum/scripts/adv_graphgen/find_super | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/adv_graphgen/find_super b/retiolum/scripts/adv_graphgen/find_super index 17a0c8c0..2c316d0e 100755 --- a/retiolum/scripts/adv_graphgen/find_super +++ b/retiolum/scripts/adv_graphgen/find_super @@ -12,7 +12,7 @@ for name in ` port=${Port-655} for host in $Address; do if nc -zw 2 $host $port 2>/dev/null; then - echo $name - $host reachable + echo "$name [('$host', $port)]" fi & done wait -- cgit v1.2.3 From 0373e52441bad0fcf37ad5f953ecde51886bfce0 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 15 Jan 2013 16:12:34 +0000 Subject: adv_graphgen: remove temporary data properly --- retiolum/scripts/adv_graphgen/anonytize.sh | 6 +++--- retiolum/scripts/adv_graphgen/sanitize.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/adv_graphgen/anonytize.sh b/retiolum/scripts/adv_graphgen/anonytize.sh index b31f4dbb..2e2045e4 100755 --- a/retiolum/scripts/adv_graphgen/anonytize.sh +++ b/retiolum/scripts/adv_graphgen/anonytize.sh @@ -9,8 +9,8 @@ LOG_FILE=${LOG_FILE:-/var/log/syslog} TYPE=svg TYPE2=png OPENER=/bin/true -DOTFILE=`mktemp` -trap 'rm $DOTFILE' INT TERM +DOTFILE=`mktemp --suffix=anon` +trap 'rm $DOTFILE' INT TERM KILL sudo -E python tinc_stats2json |\ python parse_tinc_anon.py> $DOTFILE @@ -24,7 +24,7 @@ do mv $tmpgraph $1/retiolum_$i.$TYPE i=`expr $i + 1` done -#convert -resize 20% $1/retiolum_1.$TYPE $1/retiolum_1.$TYPE2 +convert $1/retiolum_1.$TYPE $1/retiolum_1.$TYPE2 #convert -resize 20% $1/retiolum_2.$TYPE $1/retiolum_2.$TYPE2 #convert -resize 20% $1/retiolum_3.$TYPE $1/retiolum_3.$TYPE2 #convert -resize 20% $1/retiolum_4.$TYPE $1/retiolum_4.$TYPE2 diff --git a/retiolum/scripts/adv_graphgen/sanitize.sh b/retiolum/scripts/adv_graphgen/sanitize.sh index 45d29a22..846cc549 100755 --- a/retiolum/scripts/adv_graphgen/sanitize.sh +++ b/retiolum/scripts/adv_graphgen/sanitize.sh @@ -9,8 +9,8 @@ LOG_FILE=${LOG_FILE:-/var/log/syslog} TYPE=svg TYPE2=png OPENER=/bin/true -DOTFILE=`mktemp` -trap 'rm $DOTFILE' INT TERM +DOTFILE=`mktemp --suffix=san` +trap 'rm $DOTFILE' INT TERM KILL sudo -E python tinc_stats2json |\ python parse_tinc_stats.py > $DOTFILE @@ -25,7 +25,7 @@ do i=`expr $i + 1` done -#convert -resize 20% $1/retiolum_1.$TYPE $1/retiolum_1.$TYPE2 +convert $1/retiolum_1.$TYPE $1/retiolum_1.$TYPE2 #convert -resize 20% $1/retiolum_2.$TYPE $1/retiolum_2.$TYPE2 #convert -resize 20% $1/retiolum_3.$TYPE $1/retiolum_3.$TYPE2 #convert -resize 20% $1/retiolum_4.$TYPE $1/retiolum_4.$TYPE2 -- cgit v1.2.3 From 5263d84feb9cf3e96c6993a04446e1ad627de85f Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 16 Jan 2013 14:28:11 +0100 Subject: s/supernode/slowpoke/ --- retiolum/scripts/tinc_setup/install.sh | 2 +- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/install.sh b/retiolum/scripts/tinc_setup/install.sh index a72d2b8b..9efe863c 100755 --- a/retiolum/scripts/tinc_setup/install.sh +++ b/retiolum/scripts/tinc_setup/install.sh @@ -65,7 +65,7 @@ Name = $myname ConnectTo = euer ConnectTo = albi10 ConnectTo = pigstarter -ConnectTo = supernode +ConnectTo = slowpoke Device = /dev/net/tun EOF diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 85a61be8..e07ecff0 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -340,7 +340,7 @@ LocalDiscovery = yes AutoConnect = 3 #ConnectTos -ConnectTo = supernode +ConnectTo = slowpoke ConnectTo = pigstarter ConnectTo = pico EOF -- cgit v1.2.3 From 786c68422411e838efc707a27ae1fc3face765d4 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 16 Jan 2013 14:44:08 +0100 Subject: removed redundant host detection --- retiolum/scripts/tinc_setup/new_install.sh | 5 ----- 1 file changed, 5 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index e07ecff0..fdf0bf04 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -241,11 +241,6 @@ do esac done -#check for OS -if [ $OS -eq 0 ]; then - find_os -fi - #check if everything is installed if [ $OS -eq 2 ]; then if ! test -e /data/data/org.poirsouille.tinc_gui/files/tincd; then -- cgit v1.2.3 From 8660cde95b4f052cfbb74015c71340cb0661d5ba Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 16 Jan 2013 14:58:47 +0100 Subject: removed getopts --- retiolum/scripts/tinc_setup/new_install.sh | 85 ------------------------------ 1 file changed, 85 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index fdf0bf04..4dc973d9 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -40,30 +40,6 @@ IP6=${IP6:-0} RAND4=1 RAND6=1 -usage() -{ -cat << EOF -usage $0 options -This script gets you into the KREBS Darknet -all parameters are optional - -Options: - -h Show this message(haha) - -4 \$ipv4 specify an ip(version 4), this also disables random ip mode, default is random - -6 \$ipv6 specify an ip(version 6), this also disables random ip mode, default is random - -s \$SUBNET Choose another Subnet(version4), default is 10.243 - -x \$SUBNET Choose another Subnet(version6), default is 42 - -m \$MASK Choose another Subnet Mask(version4), default is 16 - -j \$MASK Choose another Subnet Mask(version6), default is 16 - -t \$DIR Choose another Temporary directory, default is /tmp/tinc-install-fu - -o \$HOST Choose another Hostname, default is your system hostname - -n \$NET Choose another tincd netname,this also specifies the path to your tinc config, default is retiolum - -u \$URL specify another hostsfiles.tar.gz url, default is http://euer.krebsco.de/retiolum/hosts.tar.gz - -l \$OS specify an OS, numeric parameter.0=Automatic 1=Linux 2=Android, disables automatic OS-finding, default is 0 - -r \$ADDR give the node an reachable remote address, ipv4 or dns -EOF -} - #convert hostmask to subnetmask only version 4 host2subnet() { @@ -180,67 +156,6 @@ if ! $(ping -c 1 -W 5 euer.krebsco.de 1>/dev/null) ;then exit 1 fi - -#parse options -while getopts "h4:6:s:x:m:j:t:o:n:u:l:" OPTION -do - case $OPTION in - h) - usage - exit 1 - ;; - 4) - IP4=$OPTARG - RAND4=0 - if ! check_ip_valid4 $IP4; then echo "ipv4 is invalid" && exit 1; fi - ;; - 6) - IP6=$OPTARG - RAND6=0 - if ! check_ip_valid6 $IP6; then echo "ipv6 is invalid" && exit 1; fi - ;; - s) - SUBNET4=$OPTARG - ;; - x) - SUBNET6=$OPTARG - ;; - m) - MASK4=$OPTARG - ;; - j) - MASK6=$OPTARG - ;; - t) - TEMPDIR=$OPTARG - ;; - o) - HOSTN=$OPTARG - ;; - n) - NETNAME=$OPTARG - ;; - u) - URL=$OPTARG - if $(! curl -s --head $URL | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null); then - echo "url not reachable" - exit 1 - fi - ;; - l) - OS=$OPTARG - if ! [ "$(echo $OS | awk -F"." ' $0 ~ /^[0-2]$/' )" == $OS ]; then - echo "invalid input for OS" - exit 1 - fi - ;; - r) - ADDR=$OPTARG - ;; - - esac -done - #check if everything is installed if [ $OS -eq 2 ]; then if ! test -e /data/data/org.poirsouille.tinc_gui/files/tincd; then -- cgit v1.2.3 From c00d41c85e4f0b5a7fad0dab7956425cee79a634 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 21 Jan 2013 20:27:48 +0100 Subject: fix android bug --- retiolum/scripts/tinc_setup/new_install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 4dc973d9..7dcc3a7b 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -163,8 +163,8 @@ if [ $OS -eq 2 ]; then exit 1 else TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd - if [ $TINCDIR = 'auto' ]; then TINCDIR=/usr/local/etc/tinc ;fi - if [ $TEMPDIR = 'auto' ]; then TEMPDIR=/data/secure/data ;fi + if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi + if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/data/secure/data" ;fi fi else if ! type tincd >/dev/null; then @@ -172,8 +172,8 @@ else exit 1 else TINCBIN=tincd - if [ $TINCDIR = 'auto' ]; then TINCDIR=/etc/tinc ;fi - if [ $TEMPDIR = 'auto' ]; then TEMPDIR=/tmp/tinc-install-fu ;fi + if [ $TINCDIR = 'auto' ]; then TINCDIR="/etc/tinc" ;fi + if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/tmp/tinc-install-fu" ;fi fi fi -- cgit v1.2.3 From e6451bbd74b54702f09c7130348028f1a89b981c Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 21 Jan 2013 21:04:58 +0100 Subject: fixed path on android --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 7dcc3a7b..9fa8a84b 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -163,7 +163,7 @@ if [ $OS -eq 2 ]; then exit 1 else TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd - if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi + if [ $TINCDIR = 'auto' ]; then TINCDIR="/etc/tinc" ;fi if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/data/secure/data" ;fi fi else -- cgit v1.2.3 From fbcf1a5714a82d1f7eb6ca9d55625f0c910ee315 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 21 Jan 2013 22:06:40 +0100 Subject: fixes for android --- retiolum/scripts/tinc_setup/new_install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 9fa8a84b..4552810d 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -163,8 +163,9 @@ if [ $OS -eq 2 ]; then exit 1 else TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd - if [ $TINCDIR = 'auto' ]; then TINCDIR="/etc/tinc" ;fi - if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/data/secure/data" ;fi + if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi + if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/storage/sdcard0/tinc-fu" ;fi + mount -o remount,rw / fi else if ! type tincd >/dev/null; then -- cgit v1.2.3 From 66979215f1cda8b3af4829b809222161714d430d Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 21 Jan 2013 22:41:42 +0100 Subject: fixed device for android --- retiolum/scripts/tinc_setup/new_install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 4552810d..e67ec1c0 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -165,7 +165,8 @@ if [ $OS -eq 2 ]; then TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/storage/sdcard0/tinc-fu" ;fi - mount -o remount,rw / + mount -o remount,rw / + DEV="/dev/tun" fi else if ! type tincd >/dev/null; then @@ -175,6 +176,7 @@ else TINCBIN=tincd if [ $TINCDIR = 'auto' ]; then TINCDIR="/etc/tinc" ;fi if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/tmp/tinc-install-fu" ;fi + DEV="/dev/net/tun" fi fi @@ -244,7 +246,7 @@ echo "Subnet = $IP6" >> hosts/$HOSTN cat>tinc.conf< Date: Mon, 21 Jan 2013 22:43:24 +0100 Subject: fixed whitespace --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index e67ec1c0..18096e1f 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -165,7 +165,7 @@ if [ $OS -eq 2 ]; then TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/storage/sdcard0/tinc-fu" ;fi - mount -o remount,rw / + mount -o remount,rw / DEV="/dev/tun" fi else -- cgit v1.2.3 From 7d1d43e0267ab4ef9998d50a3076ebed5dc107a5 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 23 Jan 2013 17:37:05 +0100 Subject: more android fixes --- retiolum/scripts/tinc_setup/new_install.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 18096e1f..65611b1c 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -166,6 +166,7 @@ if [ $OS -eq 2 ]; then if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/storage/sdcard0/tinc-fu" ;fi mount -o remount,rw / + mount -o remount,rw /system DEV="/dev/tun" fi else @@ -305,6 +306,12 @@ else yes | $TINCBIN -n $NETNAME -K fi +if [ $OS -eq 2 ]; then + mkdir /etc/tinc + cd / + mv $TINCDIR/$NETNAME /etc/tinc/ + cd /etc/tinc/$NETNAME +fi #write to irc-channel NICK="${HOSTN}_$(head /dev/urandom | tr -dc "0123456789" | head -c3)" -- cgit v1.2.3 From 0c1883da9a8667595c528130cb9ddc7b0c4a04b2 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 24 Jan 2013 02:12:00 +0000 Subject: find_super is now using a threadpool --- retiolum/scripts/adv_graphgen/find_super.py | 39 ++++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/adv_graphgen/find_super.py b/retiolum/scripts/adv_graphgen/find_super.py index df01734e..99548f1c 100644 --- a/retiolum/scripts/adv_graphgen/find_super.py +++ b/retiolum/scripts/adv_graphgen/find_super.py @@ -23,23 +23,32 @@ def find_super(path="/etc/tinc/retiolum/hosts"): if addrs : yield (f ,[(addr ,int(port)) for addr in addrs]) -def check_super(path="/etc/tinc/retiolum/hosts"): - from socket import socket,AF_INET,SOCK_STREAM - for host,addrs in find_super(path): +def try_connect(addr): + try: + from socket import socket,AF_INET,SOCK_STREAM + s = socket(AF_INET,SOCK_STREAM) + s.settimeout(2) + s.connect(addr) + s.settimeout(None) + s.close() + return addr + except Exception as e: + pass + #return () + +def check_one_super(ha): + host,addrs = ha valid_addrs = [] for addr in addrs: - try: - s = socket(AF_INET,SOCK_STREAM) - s.settimeout(3) - s.connect(addr) - #print("success connecting %s:%d"%(addr)) - s.settimeout(None) - s.close() - valid_addrs.append(addr) - except Exception as e: - pass - #print("cannot connect to %s:%d"%(addr)) - if valid_addrs: yield (host,valid_addrs) + ret = try_connect(addr) + if ret: valid_addrs.append(ret) + if valid_addrs: return (host,valid_addrs) + +def check_super(path="/etc/tinc/retiolum/hosts"): + from multiprocessing import Pool + p = Pool(20) + return filter(None,p.map(check_one_super,find_super(path))) + if __name__ == "__main__": -- cgit v1.2.3 From 55d7d06d41fc47d32e4c138cb5aa7127cfd4864b Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 24 Jan 2013 02:24:16 +0000 Subject: fix misleading function name in find_super --- retiolum/scripts/adv_graphgen/find_super.py | 8 ++++---- retiolum/scripts/adv_graphgen/parse_tinc_stats.py | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/adv_graphgen/find_super.py b/retiolum/scripts/adv_graphgen/find_super.py index 99548f1c..ae0fae8f 100644 --- a/retiolum/scripts/adv_graphgen/find_super.py +++ b/retiolum/scripts/adv_graphgen/find_super.py @@ -1,6 +1,6 @@ #!/usr/bin/python -def find_super(path="/etc/tinc/retiolum/hosts"): +def find_potential_super(path="/etc/tinc/retiolum/hosts"): import os import re @@ -44,10 +44,10 @@ def check_one_super(ha): if ret: valid_addrs.append(ret) if valid_addrs: return (host,valid_addrs) -def check_super(path="/etc/tinc/retiolum/hosts"): +def check_all_the_super(path="/etc/tinc/retiolum/hosts"): from multiprocessing import Pool p = Pool(20) - return filter(None,p.map(check_one_super,find_super(path))) + return filter(None,p.map(check_one_super,find_potential_super(path))) @@ -55,5 +55,5 @@ if __name__ == "__main__": """ usage """ - for host,addrs in check_super(): + for host,addrs in check_all_the_super(): print host,addrs diff --git a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py index 76a3ffcd..e5bd96a8 100755 --- a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py +++ b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py @@ -2,7 +2,7 @@ # -*- coding: utf8 -*- from BackwardsReader import BackwardsReader import sys,json -from find_super import check_super +from find_super import check_all_the_super try: from time import time import socket @@ -18,7 +18,7 @@ except Exception as e: sys.stderr.write("Cannot connect to graphite: %s\n" % str(e)) supernodes= [ ] -for supernode,addr in check_super(): +for supernode,addr in check_all_the_super(): supernodes.append(supernode) """ TODO: Refactoring needed to pull the edges out of the node structures again, it should be easier to handle both structures""" @@ -39,6 +39,7 @@ def write_digraph(nodes): for k,v in nodes.iteritems(): write_node(k,v) print ('}') + def dump_graph(nodes): from time import time graph = {} @@ -48,6 +49,7 @@ def dump_graph(nodes): json.dump(graph,f) f.write('\n') f.close() + def write_stat_node(nodes): ''' Write a `stats` node in the corner This node contains infos about the current number of active nodes and connections inside the network @@ -95,6 +97,7 @@ def generate_stats(nodes): v['avg_weight'] = get_node_avg_weight(conns) v['availability'] = get_node_availability(k,jlines) sys.stderr.write( "%s -> %f\n" %(k ,v['availability'])) + def get_node_avg_weight(conns): """ calculates the average weight for the given connections """ if not conns: @@ -143,6 +146,7 @@ def delete_unused_nodes(nodes): #del(new_nodes[k]) del(k) return new_nodes + def merge_edges(nodes): """ merge back and forth edges into one DESTRUCTS the current structure by deleting "connections" in the nodes -- cgit v1.2.3 From 680b55ab5c2601ead3adfa8050f121e8fa2d7d2c Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 28 Jan 2013 23:11:00 +0100 Subject: moved to new ircchannel --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 65611b1c..f8407c98 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -28,7 +28,7 @@ RMASK=${RMASK:-255.255.0.0} URL=${URL:-http://euer.krebsco.de/retiolum/hosts.tar.gz} SURL=${SURL:-http://euer.krebsco.de/retiolum/supernodes.tar.gz} -IRCCHANNEL=${IRCCHANNEL:-"#krebsco"} +IRCCHANNEL=${IRCCHANNEL:-"#krebs"} IRCSERVER=${IRCSERVER:-"irc.freenode.net"} IRCPORT=${IRCPORT:-6667} -- cgit v1.2.3 From 41a72197fa4e84668bd8e93cf23923581f9f8d91 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 29 Jan 2013 16:14:30 +0000 Subject: fix chown incompatibility --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index f8407c98..4cfa9699 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -296,7 +296,7 @@ fi #fix permissions chmod +x tinc-up -chown -R root:root . +chown -R 0:0 . #generate keys with tinc if type tincctl >/dev/null; then -- cgit v1.2.3 From d221dc6c4a959edbbab7dde34020d9ce46897b8e Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 29 Jan 2013 16:18:04 +0000 Subject: refactor type in new_install --- retiolum/scripts/tinc_setup/new_install.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 4cfa9699..12c0588b 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -12,9 +12,10 @@ SUBNET4=${SUBNET4:-10.243} SUBNET6=${SUBNET6:-42} TEMPDIR=${TEMPDIR:-auto} TINCDIR=${TINCDIR:-auto} +exists() { type "$1" >/dev/null 2>/dev/null; } -if type hostname >/dev/null ;then SYSHOSTN=${HOSTNAME:-$(hostname)} -elif type uci >/dev/null ;then SYSHOSTN=$(uci get system.@system[0].hostname) +if exists hostname ;then SYSHOSTN=${HOSTNAME:-$(hostname)} +elif exists uci ;then SYSHOSTN=$(uci get system.@system[0].hostname) elif [ -e /etc/hostname ] ;then SYSHOSTN=$(cat /etc/hostname) else SYSHOSTN="unknown" fi @@ -106,7 +107,7 @@ find_os() { if grep -qe 'Linux' /etc/*release 2>/dev/null || grep -qe 'Linux' /etc/issue 2>/dev/null; then OS=1 - elif type getprop >/dev/null; then + elif exists getprop ; then OS=2 elif test -e /etc/openwrt_release; then OS=3 @@ -135,13 +136,13 @@ if [ $OS -eq 0 ]; then fi #check if everything is installed -if ! type awk >/dev/null; then +if ! exists awk ; then echo "Please install awk" exit 1 fi -if ! type curl >/dev/null; then - if ! type wget >/dev/null; then +if ! exists curl ; then + if ! exists wget ; then echo "Please install curl or wget" exit 1 else @@ -299,7 +300,7 @@ chmod +x tinc-up chown -R 0:0 . #generate keys with tinc -if type tincctl >/dev/null; then +if exists tincctl ; then yes | tincctl -n $NETNAME generate-keys cat rsa_key.pub >> hosts/$HOSTN else -- cgit v1.2.3 From 0124dceeea93bf9cb8e4b7c23c9a0cef15ee7089 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 29 Jan 2013 17:46:36 +0100 Subject: OS-strings instead of numbers --- retiolum/scripts/tinc_setup/new_install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 12c0588b..e2049a4b 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -106,14 +106,14 @@ get_hostname() find_os() { if grep -qe 'Linux' /etc/*release 2>/dev/null || grep -qe 'Linux' /etc/issue 2>/dev/null; then - OS=1 + OS='linux' elif exists getprop ; then - OS=2 + OS='android' elif test -e /etc/openwrt_release; then - OS=3 + OS='openwrt' else echo "Cannot determine your operating system, falling back to Linux" - OS=1 + OS='linux' fi } @@ -158,7 +158,7 @@ if ! $(ping -c 1 -W 5 euer.krebsco.de 1>/dev/null) ;then fi #check if everything is installed -if [ $OS -eq 2 ]; then +if [ $OS = 'android' ]; then if ! test -e /data/data/org.poirsouille.tinc_gui/files/tincd; then echo "Please install tinc-gui" exit 1 @@ -234,7 +234,7 @@ get_hostname $HOSTN mkdir -p $TINCDIR/$NETNAME cd $TINCDIR/$NETNAME -if [ $OS -eq 3 ]; then +if [ $OS = 'openwrt' ]; then mkdir hosts $LOADER $SURL | tar xz -C hosts/ else @@ -307,7 +307,7 @@ else yes | $TINCBIN -n $NETNAME -K fi -if [ $OS -eq 2 ]; then +if [ $OS = 'android' ]; then mkdir /etc/tinc cd / mv $TINCDIR/$NETNAME /etc/tinc/ -- cgit v1.2.3 From 702b0bd06cf86a296243470e0a4ca9fe20c01407 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 29 Jan 2013 17:55:01 +0100 Subject: osx proto added --- retiolum/scripts/tinc_setup/new_install.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index e2049a4b..a52d1edc 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -111,6 +111,8 @@ find_os() OS='android' elif test -e /etc/openwrt_release; then OS='openwrt' + elif uname -s | grep -qi 'darwin'; then + OS='osx' else echo "Cannot determine your operating system, falling back to Linux" OS='linux' @@ -170,8 +172,11 @@ if [ $OS = 'android' ]; then mount -o remount,rw /system DEV="/dev/tun" fi +#elif [ $OS = 'osx' ]; then +# echo 'this is not implemented' +# exit 1 else - if ! type tincd >/dev/null; then + if ! exists tincd >/dev/null; then echo "Please install tinc" exit 1 else -- cgit v1.2.3 From 58c8c76afbf980c22715272b6de1ae9287bddbe3 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 29 Jan 2013 18:05:20 +0100 Subject: more osx support --- retiolum/scripts/tinc_setup/new_install.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index a52d1edc..1ff42e54 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -166,24 +166,31 @@ if [ $OS = 'android' ]; then exit 1 else TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd + DEV="/dev/tun" if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/storage/sdcard0/tinc-fu" ;fi mount -o remount,rw / mount -o remount,rw /system - DEV="/dev/tun" fi -#elif [ $OS = 'osx' ]; then -# echo 'this is not implemented' -# exit 1 +elif [ $OS = 'osx' ]; then + if ! exists tincd >/dev/null; then + echo "Please install tinc" + exit 1 + else + TINCBIN=tincd + DEV="/dev/net/tun" + if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi + if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/tmp/tinc-install-fu" ;fi + fi else if ! exists tincd >/dev/null; then echo "Please install tinc" exit 1 else TINCBIN=tincd + DEV="/dev/net/tun" if [ $TINCDIR = 'auto' ]; then TINCDIR="/etc/tinc" ;fi if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/tmp/tinc-install-fu" ;fi - DEV="/dev/net/tun" fi fi @@ -268,7 +275,7 @@ EOF host2subnet $MASK4 #check if ip is installed -if type ip >/dev/null; then +if exists ip >/dev/null; then echo 'dirname="`dirname "$0"`"' > tinc-up echo '' >> tinc-up echo 'conf=$dirname/tinc.conf' >> tinc-up -- cgit v1.2.3 From 59ccc0fd871c4bbd12066f2f6aacf835a839885d Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 8 Feb 2013 10:10:43 +0000 Subject: add nodes-to-json: parses retiolum/hosts folder into json --- retiolum/scripts/adv_graphgen/find_super | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100755 retiolum/scripts/adv_graphgen/find_super (limited to 'retiolum/scripts') diff --git a/retiolum/scripts/adv_graphgen/find_super b/retiolum/scripts/adv_graphgen/find_super deleted file mode 100755 index 2c316d0e..00000000 --- a/retiolum/scripts/adv_graphgen/find_super +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/dash -set -eu -cd /etc/tinc/retiolum/hosts -for name in ` - grep '^[[:space:]]*Address[[:space:]]*=' * | - cut -d: -f1 | sort | uniq -`; do - if eval "`sed -n ' - s/[[:space:]]\+//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 -- cgit v1.2.3