diff options
-rw-r--r-- | retiolum/hosts/seruundroid | 17 | ||||
-rw-r--r-- | retiolum/scripts/adv_graphgen/find_super.py | 43 | ||||
-rwxr-xr-x | retiolum/scripts/adv_graphgen/parse_tinc_stats.py | 8 | ||||
-rwxr-xr-x | retiolum/scripts/tinc_setup/new_install.sh | 7 |
4 files changed, 48 insertions, 27 deletions
diff --git a/retiolum/hosts/seruundroid b/retiolum/hosts/seruundroid index 660673fb..b4f0848e 100644 --- a/retiolum/hosts/seruundroid +++ b/retiolum/hosts/seruundroid @@ -1,11 +1,12 @@ -Subnet = 10.243.211.81 -Subnet = 42:d274:9187:9408:d5e7:05f2:ee07:9abd +Subnet = 10.243.127.2 +Subnet = 42:81de:f850:152b:0988:1942:265d:dacb -----BEGIN RSA PUBLIC KEY----- -MIIBCgKCAQEAryK+xseuc/kPjZb+uPyNiDDW4P9DVLTV/eGowHZrPcn6t7L5CUZp -jl4csKkfJs8TayM9edAitJvC3KWFmdZrV6L9LY1BmAGuJix4wr1WtdkxwC/cUUWE -I9bTqSTGrhSRxKRmO/xSB1za5oIfIQ6vnXZYXPaAFiOQj4B5m5qn79K+d3N3j3MX -BB8BEkQHNuuCTm3JIWTLT6ZSOGgKPCXnV9NR6WwdHS62SBntZQHaheirMQQ7AJAT -kiZTdrPnMap0Qm9xkMbttazgrfVNoOzCJRMOH5EyMEfc69CufOotgfJLg0Ki8aeJ -uY3wX/aLZz2HklVarvuk5gX5RqsmZXswFwIDAQAB +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/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/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)" |