diff options
author | makefu <github@syntax-fehler.de> | 2013-03-07 11:40:38 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2013-03-07 11:40:38 +0100 |
commit | 7fa8fb85b072f612adb322f8a02617e1bd737020 (patch) | |
tree | 683df8268baae71451633518aa7ff7ea258a4aa8 /retiolum | |
parent | dbe2d838ba6834788265029162b2dd7d82473335 (diff) | |
parent | ef4eb3189363f5cd9a33b43693322a68d3142979 (diff) |
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'retiolum')
29 files changed, 332 insertions, 172 deletions
diff --git a/retiolum/Makefile b/retiolum/Makefile index a8ae0973..b3a3c124 100644..100755 --- a/retiolum/Makefile +++ b/retiolum/Makefile @@ -29,3 +29,4 @@ startup: hosts: bin/update-retiolum-hosts || :; + sudo bin/patch-retiolum-hosts diff --git a/retiolum/bin/find-supernodes b/retiolum/bin/find-supernodes new file mode 100755 index 00000000..2c316d0e --- /dev/null +++ b/retiolum/bin/find-supernodes @@ -0,0 +1,21 @@ +#! /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 diff --git a/retiolum/bin/list-known-public-addresses b/retiolum/bin/list-known-public-addresses new file mode 100755 index 00000000..21b1c389 --- /dev/null +++ b/retiolum/bin/list-known-public-addresses @@ -0,0 +1,38 @@ +#! /bin/sh +# +# printf '%s %s\n' hostname IP-address for each known public retiolum address +# +set -eu + +_list_hostname_address() { + cd /etc/tinc/retiolum/hosts + grep --with-filename '^Address' * | + sed -n ' + s/: */ / + s/ *= */ / + s/ Address \([a-zA-Z0-9.:_]*\) \?.*/ \1/p' +} +_lookup_address() { + sed ' + /:/!{/ [0-9.]*$/!{s/ / `dig +short /;s/$/` \&/}} + s/^/echo / + $s/$/\nwait/ + ' | sh +} +_filter_public() { + sed ' + # drop private IPv4 addresses + / 10\./d + / 172\.\(1[6-9]\|2[0-9]\|3[01]\)\./d + / 192\.168\./d + # TODO drop private IPv6 addresses + ' +} +_filter_online() { + awk ' + {print"nc -zw 2 "$2" 655 2>/dev/null && echo "$1" "$2" &"} + END {print"wait"} + ' | sh +} + +_list_hostname_address | _lookup_address | _filter_public diff --git a/retiolum/bin/my-ip b/retiolum/bin/my-ip deleted file mode 100755 index fcfbba05..00000000 --- a/retiolum/bin/my-ip +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -curl http://euer.krebsco.de/live/ip.php diff --git a/retiolum/bin/nodes-to-json.py b/retiolum/bin/nodes-to-json.py new file mode 100644 index 00000000..ca9d3c8c --- /dev/null +++ b/retiolum/bin/nodes-to-json.py @@ -0,0 +1,37 @@ +#!/usr/bin/python + +def parse_hosts_path(path="/etc/tinc/retiolum/hosts"): + import os + import re + + needle_addr = re.compile("Subnet\s*=\s*(.*)/[0-9]+") + needle_port = re.compile("Port\s*=\s*(.*)") + for f in os.listdir(path): + with open(path+"/"+f) as of: + addrs = [] + port = "655" + + for line in of.readlines(): + + addr_found = needle_addr.match(line) + if addr_found: + addrs.append(addr_found.group(1)) + + port_found = needle_port.match(line) + if port_found: + port = port_found.group(1) + + if addrs : yield (f ,[(addr ,int(port)) for addr in addrs]) + + + +if __name__ == "__main__": + """ + usage + """ + import json + import sys + db={} + for host,addrs in parse_hosts_path(sys.argv[1] if len(sys.argv) > 2 else "/etc/tinc/retiolum/hosts"): + db[host] = addrs + print(json.dumps(db)) diff --git a/retiolum/bin/patch-retiolum-hosts b/retiolum/bin/patch-retiolum-hosts new file mode 100755 index 00000000..69d7b92c --- /dev/null +++ b/retiolum/bin/patch-retiolum-hosts @@ -0,0 +1,13 @@ +#! /bin/sh +# +# Apply custom retiolum hosts patches, if any. +# +# usage: patch-retiolum-hosts [--reverse] +# +set -euf + +patch=/etc/tinc/retiolum/hosts.patch + +if test -e $patch; then + patch -N -d /etc/tinc/retiolum/hosts -r - "$@" < $patch +fi diff --git a/retiolum/bin/update-retiolum-hosts b/retiolum/bin/update-retiolum-hosts index 2a379459..214ac205 100755 --- a/retiolum/bin/update-retiolum-hosts +++ b/retiolum/bin/update-retiolum-hosts @@ -1,5 +1,5 @@ #! /bin/sh -set -eu +set -euf if test "${nosudo-false}" != true -a `id -u` != 0; then echo "we're going sudo..." >&2 @@ -11,6 +11,4 @@ fi cd $(dirname $(readlink -f $0))/.. mkdir -p /etc/tinc/retiolum/hosts -cp -v -r hosts/* /etc/tinc/retiolum/hosts -pkill -HUP tincd -pkill -ALRM tincd +rsync -va --delete hosts/ /etc/tinc/retiolum/hosts/ diff --git a/retiolum/bin/update_tinc_hosts b/retiolum/bin/update_tinc_hosts index 7be30c2a..ce1be497 100755 --- a/retiolum/bin/update_tinc_hosts +++ b/retiolum/bin/update_tinc_hosts @@ -7,8 +7,12 @@ if test "${nosudo-false}" != true -a `id -u` != 0; then exit 23 # go to hell fi -DIRNAME=`dirname $0` -export PATH="`readlink -f $DIRNAME`:$PATH" +list_hosts="$( + basename="`readlink -f "$0"`" + bindir="`dirname "$basename"`" + echo "$bindir/hosts" +)" +hosts() { "$list_hosts"; } hosts="${hosts-/etc/hosts}" diff --git a/retiolum/hosts/Discordius b/retiolum/hosts/Discordius new file mode 100644 index 00000000..561b28ca --- /dev/null +++ b/retiolum/hosts/Discordius @@ -0,0 +1,11 @@ +Subnet = 10.243.144.246 +Subnet = 42:017a:4584:17e1:685a:3991:6533:067b + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAsOoWkyydyfW9ml7SBV8d+qXU8E1c4l0vEpdBnmOouZozo1bzzkH3 +bLn2DkZaOLCqVUC1twbeGi2a7tXHh4dLvkIcT38V3XbEwxHhMn7enpKr79GO/VFf +Lu8t5dLbmPFFTOEeC54ke8X4MdlMrUMuXiGspnl/vc1NBSJIVECl6zdqvZt/UTWA +vI7evk3F+Tf5dPATqSMdxE5506i2y/W6obwYwaXdPbyBsAQkgdTjfVUe2u0GKfld +/THprmZYTwlBEZ3YAf12OdfO1aRsDpbogpZs/rcnebScDj7myzh7FkLHdH9nIfxg +dfGxSBV7kRMwQmgfKjp/yETPjvRz0OMZoQIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/retiolum/hosts/alphalabs b/retiolum/hosts/alphalabs index e7265e67..a2e1032c 100644 --- a/retiolum/hosts/alphalabs +++ b/retiolum/hosts/alphalabs @@ -1,6 +1,5 @@ -Address = 10.9.0.10 Subnet = 42:0:0:0:0:0:0:a1fa/128 -Subnet = 10.243.0.10/32 +Subnet = 10.243.1.10/32 Compression = 9 -----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEAvUAbMmmOFn+4kOvJAvmi0R/XCQa1YBlkjUvC6Pmt0Q8gV1DodXjB diff --git a/retiolum/hosts/Shepherd b/retiolum/hosts/devstar index 875f62e2..875f62e2 100644 --- a/retiolum/hosts/Shepherd +++ b/retiolum/hosts/devstar diff --git a/retiolum/hosts/geisha b/retiolum/hosts/geisha new file mode 100644 index 00000000..6a3a2788 --- /dev/null +++ b/retiolum/hosts/geisha @@ -0,0 +1,11 @@ +Subnet = 10.243.175.29 +Subnet = 42:b6aa:9052:fffc:807b:4829:8756:860c + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA0kVV9ezFx/kZ6GvSALhXODkWlwHSjdA5hBJ90bdNcILeltVa3FIv +K2E+L6EG/jsETWKutxOk08+B/Z3p1SONgEksTNBdXx/Crww5PZGN/ocVSKZj61/N +lCej/Jcu88a4/R7JHIiSMdmqRCGHnwnxRA0iDQZIunriUH83NqMBQk6Drkphr/9a +5U8PhlqC5oSzZrg0uReRuBK86KmU03vp9/DndaLn18G835dtWRBQ2aEfIrrlaTPJ +ZKN/0xYZJU3v8YJYPi+UeRSymecSNgFQg36v95r3s4j3trk+yXVzVwT347AZRm4a +d/AHdk0+blXyUr5CFBsjA71cJfzqIIJJrwIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/retiolum/hosts/ire b/retiolum/hosts/ire new file mode 100644 index 00000000..724158cb --- /dev/null +++ b/retiolum/hosts/ire @@ -0,0 +1,12 @@ +Address = 198.147.23.143 +Subnet = 10.243.231.66 +Subnet = 42:b912:0f42:a82d:0d27:8610:e89b:490c + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAwofjmP/XBf5pwsJlWklkSzI+Bo0I0B9ONc7/j+zpbmMRkwbWk4X7 +rVLt1cWvTY15ujg2u8l0o6OgEbIkc6rslkD603fv1sEAd0KOv7iKLgRpE9qfSvAt +6YpiSv+mxEMTpH0g36OmBfOJ10uT+iHDB/FfxmgGJx//jdJADzLjjWC6ID+iGkGU +1Sf+yHXF7HRmQ29Yak8LYVCJpGC5bQfWIMSL5lujLq4NchY2d+NZDkuvh42Ayr0K +LPflnPBQ3XnKHKtSsnFR2vaP6q+d3Opsq/kzBnAkjL26jEuFK1v7P/HhNhJoPzwu +nKKWj/W/k448ce374k5ycjvKm0c6baAC/wIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/retiolum/hosts/ire2 b/retiolum/hosts/ire2 new file mode 100644 index 00000000..6b9d0a79 --- /dev/null +++ b/retiolum/hosts/ire2 @@ -0,0 +1,9 @@ + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAwXkn0H/+BUiARYSzZCpjqEwGeDZsbRHoWcRNlmlP6XjPMbKKQBHf +gdERPevhoGaNtQdW6SEA5xb1cJDHZILHZtpJ63hs6999gB9x/n4x7eR6C9d7HPDD +rGv+tBdwo8QWOIQIVnSAr6WdduSg2CyZbHd6d2Xd12vrfqJxnODSUHibrUusEc/D +XBK2n1un3znzk7P+KT0xXMtNPU2678tGuwsvSIOoDfDx9+2xuxGANeqvEOeSAgg/ +SUH5CbcAFI2/4AKWP4e/yxM26YoKdz1Fu/hx7WqKwYmPERrgcr8ienx4WFGG83AJ +CmiYwO23L4qSp1KZT8SbGDh2YpamZg2BZwIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/retiolum/hosts/kvasir b/retiolum/hosts/kvasir new file mode 100644 index 00000000..6e5772a5 --- /dev/null +++ b/retiolum/hosts/kvasir @@ -0,0 +1,10 @@ +Subnet = 10.243.222.181 +Subnet = 42:77e5:5496:7cd9:78aa:c4ab:ca70:6860 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAv8wui/1n4VhSd8BK1yswCrHydiYFx/+5Jdi7cB+S+qJU0FCsKs7i +9BdrTcJ+djBn6WXA6UXSHtQxoRPqT4OH9nW4HnXaMGvJJbJhHtX6C/Kun1p66zUE +oEBV0+WqSvN7+xgsMxoXjxB4YMmvMyI5zSl0uEx3sBfvkftoISQHruD3PoWInE9H +CfVcuk1qzvsbk23uEyGjS1k6z0rI/HunmcEHw1r3oTAgFg7ZXH9ElCBBDbwECjMI +x+DREZlH3kqJ/W4ulg6+tf9bh/22oBbJu2H4hza9k8lx4z1jUARqeJVhNVKOiyXM +l8rFUiGAXortMoSlslnPXvShSuskMJP2CQIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/retiolum/hosts/nfcgate_298dbf07 b/retiolum/hosts/nfcgate_298dbf07 new file mode 100644 index 00000000..e3936b07 --- /dev/null +++ b/retiolum/hosts/nfcgate_298dbf07 @@ -0,0 +1,10 @@ +Subnet = 10.243.32.21 +Subnet = 42:9ca7:c370:a9d9:ee1b:623b:7fe6:5146 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEApPJKpk2vFwG0GSjl/Sg2IMfala2bOYSnTDO13AHIuybfmNr3H3O7 +exJ/ALN5lqnVOU5pL9GyORnAEEeaVI+eGJmQJwTtQExoLo3o12YT+mDV8YFYVqo8 +ZYQqxLlNO1gNKNDHPlZoCmwtavmv8jqGyitjCT8ZHDHiGl/ugddNOwfFHcSM1a9c +rAM4+D3Qu8YCIC3txcww77UtbFZVBQDG3UxkGbqNeD7Je1QHyZxPs0Oqj3aIYHLP +MW4H4360dW8+3U12bwYU4viD/uyCflrFvI2nY47GzF2MakC7UeUEiVDw7U9627wq +ra6GQebx7NRZjg/pTy77uxj7RFIHRFyIEQIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/retiolum/hosts/nomic2 b/retiolum/hosts/nomic2 new file mode 100644 index 00000000..63d83ff5 --- /dev/null +++ b/retiolum/hosts/nomic2 @@ -0,0 +1,10 @@ +Subnet = 10.243.0.111/32 +Subnet = 42:02d5:733f:d6da:c0f5:2bb7:2b18:09ed/128 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA4RATrMG+MJyNq77+qUqoXkBIpUeytIvUNXT5OdvU5v91Xo2eGI23 +NXiFtILDb1nEPB+L4vVWkUKRuPAy+ThgqgTH1vyugT6jRoRhWWmGmSn2GjaF+UxK +edTfGJqO0Iwn0kZsIFxXUibkmG5iRbJBoPXXz33VtNxOv2gZZ6klfv/pYWnrxmLm +RZXkE1H3Y0U2ulQEXvpexzVscfYmlAw7h0Ew4aaY2LK4spLLPjx9RdDgfwZOZdS+ +gi5cmi/qM71/o67/4XippR9+7GQ8YecbeoR4bcZpDNoDy1ri7HPPu/t6CiqsYVyg +jYGBm+IGbwI9hxGel2bXCVBGLE7gpN51TwIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/retiolum/hosts/rage b/retiolum/hosts/rage new file mode 100644 index 00000000..35da19f6 --- /dev/null +++ b/retiolum/hosts/rage @@ -0,0 +1,12 @@ +Address = 192.40.56.122 +Subnet = 10.243.211.81 +Subnet = 42:73d5:8402:f8f1:0250:0bc3:e2ec:850d + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA6dOSRjCwkdx/nOSQwiiCw889YBSlf0ZAymBSaWJ+XdLnktqqZIvQ ++1RMdfpTTsIaHoLDwvBI6gW9dhV5MEeP3AlWfKPZAMCWg8l3PkTERZILWGSLiizs +zCyJgLpsb2MP7rT3RlLlHyTNdx9QXxDX2K1Y/fJsjXuTTgwg3JPlPM2huGTZtWgM +GDFsRpfe37hIuIheYBgnP99OvEgx3rLyCDvd16kIMd2Pjx4SouVQqaBmvEmg+UEH +zD79GaO7c2xkqq6JggJw1q/xZnH+5CF8280kh/niXVqy8R/hP75FU1rvjHnMJvfo +nyPGC8ir2m6iy4CR07YBIYo1PRTXGDC1vwIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/retiolum/hosts/rubus b/retiolum/hosts/rubus index 0ba98c0d..e5f0a729 100644 --- a/retiolum/hosts/rubus +++ b/retiolum/hosts/rubus @@ -1,11 +1,10 @@ -Subnet = 10.243.137.174 -Subnet = 42:7941:278b:bd29:f0ab:9c09:e5e9:7965 - +Subnet = 10.0.7.7.55 +Subnet = 42:537a:0c95:6315:6598:e109:74b2:0887/128 -----BEGIN RSA PUBLIC KEY----- -MIIBCgKCAQEAznS+XyF278SXTVgK9OG8SDu+pffDZtBeYfyyNHAVt/2EeE3cfIJZ -3iBXMcD8/yelCWMY6S+MNNnP+KqyCCVuG8rvhpMjB/RGzqLFSTLZoQOmC/O9S3i3 -TKKr4zxyBxjSFAPSOeHbrERAyREg/GNrLxX/SzT/yOgRDjZLA1Z5CgunXVeiB7BF -9jL1U6AahFD/6NzaPAc4+mSAQJzGw4P5TeVvAlhf96x5I0sBc09Vu87sL9NJOpi8 -hqWYhLWjZF4CRusjV3SL9kUj668CZO1S9Ooe3FO37Pa0fftDLQekCpBDrtoNr6LW -O2BYBEXsQn5ooZgAysm7mi9Hbdc3dPl5/QIDAQAB +MIIBCgKCAQEAqudpo1cC1ETPA3d16cNTAwwud195Yetdx32ty5/VkY2KgLnnl672 +XTPZBVhFppG+NU6QIYq2c0+BdUV+42XNnSeTKy79xr49eSMDaAXuWiX4eY8dh4v9 +n7elTWikzTaElS5SI3wcJPz8SdajWclnRkqXbyMY7Pw7uJMgT3svC/chN8tgp1LT +2s1DdvxaHhnFPef2NQvIWgfgytReLB8dQnSYoAiwIGvNXQT4OXgshJkTAwmok/Sq +io8K1FeJyOranBM/ZyYbQWMEXuknoJ9PXKPbrGjD+ftS18Gs75ODWqh/Bpj75rpT +q6HLJv6H6YpToxueTL1iYM00MNW4g/oPZQIDAQAB -----END RSA PUBLIC KEY----- diff --git a/retiolum/hosts/seruundroid b/retiolum/hosts/seruundroid new file mode 100644 index 00000000..b4f0848e --- /dev/null +++ b/retiolum/hosts/seruundroid @@ -0,0 +1,12 @@ +Subnet = 10.243.127.2 +Subnet = 42:81de:f850:152b:0988:1942:265d:dacb + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAvNtSbaaacF05L2mAxxA5SYc6DuoZEAkXlhcvLTlpu9f/0vZwUWh7 +175pLn6VqUijVoFb9vyoOwkrs9Uk3aX8mYws+5yJLwXhIje+U3uiVTphowKva+m9 +BzV6waZ5dLbh+3CGimx1TBkFTly3NkdZs886QWSO4aXLdU6lt3jRYsuay0Eop/j0 +eQ0BWg9o0QEcfDRQ7RirXrD0B7TSo6qZC0b4NSAMHTE+dvOMo7c+Z7cIPNLS0B+T +Am7ju3gF7UU68kKPyczrNSPPPZayEvZYUZE4PHt8dyIsppojoRq0SJqsMr/mOC15 +dg/KnoKezn9nqUWzisRWrrqWStAKITJkjQIDAQAB +-----END RSA PUBLIC KEY----- + diff --git a/retiolum/hosts/slowpoke b/retiolum/hosts/slowpoke new file mode 100644 index 00000000..e5cf70bf --- /dev/null +++ b/retiolum/hosts/slowpoke @@ -0,0 +1,13 @@ +Address = 81.89.96.210 +Subnet = 10.243.232.121 +Subnet = 42:7d8f:9e3a:dcc7:9b22:d1ca:7e28:fe9c + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA9EtaOHLa0CyOGpX3rzMLqi9HqrjzVe3XdSfcb9QPYwcbxpPYNLLk +/1+4vxOI/TEh1QCu0bzPLy8tAwKF2DwnCH72yae17I0jVMW29Ng3Fdjzb3SmWJbf +C87X7c+Nx5+Yc7OIdvTi/BGPNpDEp7nJugubH1whSFfulCDbsGU3rX5IsDUiw4ha +B+5wH1coQl+Yp+M1ws5+PoHgYQ/ApYPBKEn+H7JAdnOTLbo0eI3B1PuDUrsMakMq +s4f74d2Z405xUGHhRRcerF0h5VD58TADxx7RSRd7oR06KlXM/RaqOkw9vzvA2vBq +CC+LdtIV7wWxF3uRAnk6odeFvqZTHvR4WQIDAQAB +-----END RSA PUBLIC KEY----- + diff --git a/retiolum/hosts/wookBox b/retiolum/hosts/wookBox new file mode 100644 index 00000000..5f1fac86 --- /dev/null +++ b/retiolum/hosts/wookBox @@ -0,0 +1,10 @@ +Subnet = 10.243.129.48 +Subnet = 42:b4f7:9cc9:b129:47a2:fb17:704a:9242 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA1Sh6ue0vNr6MU80p04d93k50Fb1nMob3JB/c2OnGQb+QTKiaSFmS +gyUT1V7UFgcxsXlnvpGpez0MwSW908PyhUS9urO7bedi9O4jKy0fD4sKyRXY4ob7 +R1Z45bMLaRj/25IYqrr/cecDb9/dyMlVU0CiUQY/O9hJvuuUEWYhJO0ubHU2eMoY +I7cgx7FaxgxVJH1g3u/Ol+Q73oX3HHUt2qk3SuSDi4JklMY+9wysW7GfrcpK3h5o +jX3J9X7nCMitIstGPNrjIoKXWNH1Dbzwq0yW3XOo3TlOtecwG1G5g9Gz+HcdjoHa +2jL0AjWtm2klOCXnuq5xe2WJ5wjqzzemWQIDAQAB +-----END RSA PUBLIC KEY----- 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/find_super b/retiolum/scripts/adv_graphgen/find_super deleted file mode 100644 index c89a94fb..00000000 --- a/retiolum/scripts/adv_graphgen/find_super +++ /dev/null @@ -1,14 +0,0 @@ -#!/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" - - fi - done -done diff --git a/retiolum/scripts/adv_graphgen/find_super.py b/retiolum/scripts/adv_graphgen/find_super.py index df01734e..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 @@ -23,28 +23,37 @@ 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_all_the_super(path="/etc/tinc/retiolum/hosts"): + from multiprocessing import Pool + p = Pool(20) + return filter(None,p.map(check_one_super,find_potential_super(path))) + 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 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 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..1ff42e54 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 @@ -28,7 +29,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} @@ -40,30 +41,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() { @@ -129,14 +106,16 @@ get_hostname() 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 - OS=2 + OS='linux' + elif exists getprop ; then + OS='android' elif test -e /etc/openwrt_release; then - OS=3 + OS='openwrt' + elif uname -s | grep -qi 'darwin'; then + OS='osx' else echo "Cannot determine your operating system, falling back to Linux" - OS=1 + OS='linux' fi } @@ -159,13 +138,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 @@ -180,90 +159,38 @@ 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 for OS -if [ $OS -eq 0 ]; then - find_os -fi - #check if everything is installed -if [ $OS -eq 2 ]; then +if [ $OS = 'android' ]; then if ! test -e /data/data/org |