summaryrefslogtreecommitdiffstats
path: root/retiolum
diff options
context:
space:
mode:
authorYour Name <you@example.com>2013-02-08 10:12:00 +0000
committerYour Name <you@example.com>2013-02-08 10:12:00 +0000
commit866a6db6f68fe4ccbfea4eb26b37dc5233b00c24 (patch)
tree733f6aad506ee9195653bf5d725b964879454b5d /retiolum
parentddd9f8791eea0e810682ab66d951571417ebc8d3 (diff)
parent194e1622b0b901780ceea40ea9c453c573b69995 (diff)
Merge branch 'master' of https://github.com/krebscode/painload
Diffstat (limited to 'retiolum')
-rwxr-xr-xretiolum/bin/find-supernodes (renamed from retiolum/scripts/adv_graphgen/find_super)0
-rwxr-xr-xretiolum/bin/my-ip2
-rw-r--r--retiolum/bin/nodes-to-json.py37
3 files changed, 37 insertions, 2 deletions
diff --git a/retiolum/scripts/adv_graphgen/find_super b/retiolum/bin/find-supernodes
index 2c316d0e..2c316d0e 100755
--- a/retiolum/scripts/adv_graphgen/find_super
+++ b/retiolum/bin/find-supernodes
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))