summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYour Name <you@example.com>2013-02-05 12:29:45 +0000
committerYour Name <you@example.com>2013-02-05 12:29:45 +0000
commitc5bd7df1ba5839e1a5a018381a109025d7bb3c6a (patch)
treeddee180f43a9300c2be09e6676f781e8f0462a4b
parentb55bb65e05f6645d87470b94ef56ec0c3d6c160d (diff)
parent5b87cdd1f83e8191f01ac9e9c3441e2a47874a20 (diff)
Merge branch 'master' of https://github.com/krebscode/painload
-rwxr-xr-xretiolum/bin/list-known-public-addresses38
-rw-r--r--retiolum/hosts/Discordius11
-rw-r--r--retiolum/hosts/nomic210
-rw-r--r--util/lib/geo/Makefile15
-rw-r--r--util/lib/geo/index.js48
-rw-r--r--util/lib/geo/package.json7
6 files changed, 129 insertions, 0 deletions
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/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/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/util/lib/geo/Makefile b/util/lib/geo/Makefile
new file mode 100644
index 00000000..d13cd471
--- /dev/null
+++ b/util/lib/geo/Makefile
@@ -0,0 +1,15 @@
+all: node_modules GeoLiteCity.dat
+
+node_modules: package.json
+ npm install
+ @touch -r $< $@
+
+GeoLiteCity.dat:
+ @test -e GeoLiteCity.dat && ln -s GeoLiteCity.dat $@ || { \
+ echo 'No GeoIP City database found.'; \
+ echo 'You can get one from http://dev.maxmind.com/geoip/geolite:'; \
+ echo ' wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz'; \
+ echo ' gunzip GeoLiteCity.dat.gz'; \
+ exit 23; \
+ }
+
diff --git a/util/lib/geo/index.js b/util/lib/geo/index.js
new file mode 100644
index 00000000..0763b1a4
--- /dev/null
+++ b/util/lib/geo/index.js
@@ -0,0 +1,48 @@
+function slurp (stream, callback) {
+ var data = []
+ stream.on('data', function (chunk) {
+ data.push(chunk)
+ })
+ stream.on('end', function () {
+ callback(null, Buffer.concat(data))
+ })
+ stream.resume()
+}
+
+
+var path = require('path')
+var city_dat = path.join(__dirname, 'GeoLiteCity.dat')
+
+var geoip = require('geoip')
+var city = new geoip.City(city_dat)
+
+slurp(process.stdin, function (err, data) {
+ var lines = data.toString().split('\n')
+ // remove last, empty element (caused by the [mandatory] final \n)
+ if (lines.length > 1 && lines[lines.length - 1] === '') {
+ lines.pop()
+ }
+ var name = 0, addr = 1
+ lines
+ .map(function (line) { return line.split(' ') })
+ .forEach(function (host) {
+ //city.lookup(host[addr], function (err, loc) {
+ // if (err) {
+ // console.error('#', host[name], err.message)
+ // } else {
+ // console.log(host[name] + ': ' + loc.longitude + ',' + loc.latitude)
+ // }
+ //})
+ var loc = city.lookupSync(host[addr])
+ //if (!loc) { console.error('#', host[name]) }
+ if (loc) {
+ var a = loc.latitude
+ var b = loc.longitude
+ //var c = loc.altitude
+ //var geo = 'geo:' + [a,b,c].join(',')
+ var geo = 'geo:' + [a,b].join(',')
+
+ console.log(host[name], geo)
+ }
+ })
+})
diff --git a/util/lib/geo/package.json b/util/lib/geo/package.json
new file mode 100644
index 00000000..ad449a62
--- /dev/null
+++ b/util/lib/geo/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "geo",
+ "version": "0.0.0",
+ "dependencies": {
+ "geoip": "*"
+ }
+}