diff options
-rwxr-xr-x | retiolum/bin/find-active-nodes | 21 | ||||
-rw-r--r-- | retiolum/hosts/Lassulus | 1 | ||||
-rw-r--r-- | retiolum/hosts/alphalabs | 1 | ||||
-rw-r--r-- | retiolum/hosts/wookBox | 10 | ||||
-rw-r--r-- | retiolum/scripts/adv_graphgen/find-all-nodes.py | 59 |
5 files changed, 90 insertions, 2 deletions
diff --git a/retiolum/bin/find-active-nodes b/retiolum/bin/find-active-nodes new file mode 100755 index 00000000..2c316d0e --- /dev/null +++ b/retiolum/bin/find-active-nodes @@ -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/hosts/Lassulus b/retiolum/hosts/Lassulus index 98bd01e0..be9782b1 100644 --- a/retiolum/hosts/Lassulus +++ b/retiolum/hosts/Lassulus @@ -1,6 +1,5 @@ Subnet = 42:0:0:0:0:0:0:dea7/128 Subnet = 10.243.0.2/32 -Compression = 9 -----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEAsj1PCibKOfF68gmFQ+wwyfhUWpqKqpznrJX1dZ+daae7l7nBHvsE H0QwkiMmk3aZy1beq3quM6gX13aT+/wMfWnLyuvT11T5C9JEf/IS91STpM2BRN+R diff --git a/retiolum/hosts/alphalabs b/retiolum/hosts/alphalabs index a2e1032c..e5f98d69 100644 --- a/retiolum/hosts/alphalabs +++ b/retiolum/hosts/alphalabs @@ -1,6 +1,5 @@ Subnet = 42:0:0:0:0:0:0:a1fa/128 Subnet = 10.243.1.10/32 -Compression = 9 -----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEAvUAbMmmOFn+4kOvJAvmi0R/XCQa1YBlkjUvC6Pmt0Q8gV1DodXjB DgwP8yhLcxaVy2Hk82aJvNTUrfMeB2sdt1RJHQiEPQkHthdp8Spm0Px4uTiMjmFB 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/find-all-nodes.py b/retiolum/scripts/adv_graphgen/find-all-nodes.py new file mode 100644 index 00000000..ae0fae8f --- /dev/null +++ b/retiolum/scripts/adv_graphgen/find-all-nodes.py @@ -0,0 +1,59 @@ +#!/usr/bin/python + +def find_potential_super(path="/etc/tinc/retiolum/hosts"): + import os + import re + + needle_addr = re.compile("Address\s*=\s*(.*)") + 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]) + +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: + 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_all_the_super(): + print host,addrs |