summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts
diff options
context:
space:
mode:
authorLassulus <lassulus@googlemail.com>2012-12-09 03:06:58 +0100
committerLassulus <lassulus@googlemail.com>2012-12-09 03:06:58 +0100
commit85af484348ac6ad8ca6b9bf992ecf8b63b4ec587 (patch)
tree507466a4e172e033bb2e13e0083f875200ed6bd3 /retiolum/scripts
parent8c11e39a58e69de9b1912756082609f5ffb0dcb1 (diff)
parentd263d0e9e7e6c37f793eb3ec1908d188849f5d02 (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'retiolum/scripts')
-rwxr-xr-xretiolum/scripts/adv_graphgen/anonytize.sh2
-rwxr-xr-xretiolum/scripts/adv_graphgen/sanitize.sh2
-rwxr-xr-xretiolum/scripts/adv_graphgen/tinc_stats.py83
-rwxr-xr-xretiolum/scripts/tinc_setup/install.sh2
-rw-r--r--retiolum/scripts/tinc_setup/write_channel.py27
5 files changed, 3 insertions, 113 deletions
diff --git a/retiolum/scripts/adv_graphgen/anonytize.sh b/retiolum/scripts/adv_graphgen/anonytize.sh
index d49793cb..dec6e456 100755
--- a/retiolum/scripts/adv_graphgen/anonytize.sh
+++ b/retiolum/scripts/adv_graphgen/anonytize.sh
@@ -11,7 +11,7 @@ TYPE2=png
OPENER=/bin/true
DOTFILE=`mktemp`
trap 'rm $DOTFILE' INT TERM
-sudo LOG_FILE=$LOG_FILE python tinc_stats.py |\
+sudo LOG_FILE=$LOG_FILE python ../../tinc_stats2json |\
python parse_tinc_anon.py> $DOTFILE
diff --git a/retiolum/scripts/adv_graphgen/sanitize.sh b/retiolum/scripts/adv_graphgen/sanitize.sh
index c46662f3..78d74ce6 100755
--- a/retiolum/scripts/adv_graphgen/sanitize.sh
+++ b/retiolum/scripts/adv_graphgen/sanitize.sh
@@ -11,7 +11,7 @@ TYPE2=png
OPENER=/bin/true
DOTFILE=`mktemp`
trap 'rm $DOTFILE' INT TERM
-sudo LOG_FILE=$LOG_FILE python tinc_stats.py |\
+sudo LOG_FILE=$LOG_FILE python ../../tinc_stats2json |\
python parse_tinc_stats.py > $DOTFILE
diff --git a/retiolum/scripts/adv_graphgen/tinc_stats.py b/retiolum/scripts/adv_graphgen/tinc_stats.py
deleted file mode 100755
index d0d47aff..00000000
--- a/retiolum/scripts/adv_graphgen/tinc_stats.py
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/python
-from BackwardsReader import BackwardsReader
-import os
-import re
-import sys
-import json
-
-
-TINC_NETWORK = os.environ.get("TINC_NETWORK","retiolum")
-os.environ["LOG_FILE"]
-SYSLOG_FILE = os.environ.get("LOG_FILE","/var/log/everything.log")
-
-
-# Tags and Delimiters
-TINC_TAG="tinc.%s" % TINC_NETWORK
-BEGIN_NODES = "Nodes:"
-END_NODES = "End of nodes."
-BEGIN_SUBNET = "Subnet list:"
-END_SUBNET = "End of subnet list"
-BEGIN_EDGES = "Edges:"
-END_EDGES = "End of edges."
-
-def get_tinc_block(log_file):
- """ returns an iterateable block from the given log file (syslog) """
- tinc_block = []
- in_block = False
- bf = BackwardsReader(log_file)
- BOL = re.compile(".*tinc.retiolum\[[0-9]+\]: ")
- while True:
- line = bf.readline()
- if not line:
- raise Exception("end of file at log file? This should not happen!")
- line = BOL.sub('',line).strip()
-
- if END_SUBNET in line:
- in_block = True
-
- if not in_block:
- continue
-
- tinc_block.append(line)
-
- if BEGIN_NODES in line:
- break
- return reversed(tinc_block)
-
-def parse_input(log_data):
- nodes={}
- for line in log_data:
- if BEGIN_NODES in line :
- nodes={}
- for line in log_data:
- if END_NODES in line :
- break
- l = line.replace('\n','').split() #TODO unhack me
- nodes[l[0]]= { 'external-ip': l[2], 'external-port' : l[4] }
- if BEGIN_SUBNET in line :
- for line in log_data:
- if END_SUBNET in line :
- break
- l = line.replace('\n','').split()
- if not nodes[l[2]].get('internal-ip',False):
- nodes[l[2]]['internal-ip'] = []
- nodes[l[2]]['internal-ip'].append(l[0].split('#')[0])
- if BEGIN_EDGES in line :
- edges = {}
- for line in log_data:
- if END_EDGES in line :
- break
- l = line.replace('\n','').split()
-
- if not nodes[l[0]].has_key('to') :
- nodes[l[0]]['to'] = []
- nodes[l[0]]['to'].append(
- {'name':l[2],'addr':l[4],'port':l[6],'weight' : l[10] })
- return nodes
-
-
-if __name__ == '__main__':
- import subprocess,time
- subprocess.call(["pkill","-SIGUSR2", "tincd"])
- time.sleep(1)
- print json.dumps(parse_input((get_tinc_block(SYSLOG_FILE))))
diff --git a/retiolum/scripts/tinc_setup/install.sh b/retiolum/scripts/tinc_setup/install.sh
index a6b50b8a..2e36b83a 100755
--- a/retiolum/scripts/tinc_setup/install.sh
+++ b/retiolum/scripts/tinc_setup/install.sh
@@ -73,7 +73,7 @@ if [ ! -e rsa_key.priv ]
then
echo "creating new keys"
tincd -n $netname -K
- python ${CURR}/write_channel.py $myname || \
+ $MYBIN/announce_pubkey $myname || \
echo "cannot write public key to IRC, you are on your own. Good Luck"
else
echo "key files already exist, skipping"
diff --git a/retiolum/scripts/tinc_setup/write_channel.py b/retiolum/scripts/tinc_setup/write_channel.py
deleted file mode 100644
index 8299fa8d..00000000
--- a/retiolum/scripts/tinc_setup/write_channel.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-import random, sys, time, socket
-try:
- myname=sys.argv[1]
-except:
- print("you are made of stupid")
- exit (23)
-
-CHANNEL = '#krebsco'
-HOST='irc.freenode.net'
-FILE="/etc/tinc/retiolum/hosts/"+myname
-PORT=6667
-NICK= myname+"_"+str(random.randint(23,666))
-
-print("Connecting...")
-sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-sock.connect((HOST,PORT))
-print(NICK)
-sock.send("NICK %s\r\n" % NICK)
-sock.send("USER %s %s bla : %s\r\n" %(NICK,HOST,NICK))
-sock.send("JOIN %s\r\n" % CHANNEL)
-time.sleep(23)
-f = open(FILE,'r')
-a = [ sock.send("PRIVMSG %s : %s" % ( CHANNEL,line)) for line in f]
-time.sleep(5) #because irc is so lazy
-print("closing socket")
-sock.close()