From b98754a6459d0a96c60dfb7bc9c1b77edaffc88f Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Sun, 15 Jan 2017 21:55:41 +0100 Subject: [PATCH] use A records eq to 10-0-0-1.example.com --- README.md | 27 +++++++++++++++++++++++++++ dist.sh | 26 -------------------------- dist.version | 1 - src/{backend.py => nip.py} | 27 ++++++++++++++++++++++----- 4 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 README.md delete mode 100755 dist.sh delete mode 100644 dist.version rename src/{backend.py => nip.py} (84%) mode change 100755 => 100644 diff --git a/README.md b/README.md new file mode 100644 index 0000000..f0cfd4e --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Fork of nip.io + +This is a fork of http://nip.io with some neat changes. + +## ABOUT + +Dead simple wildcard DNS for any IP Address + +NIP.IO allows you to map any IP Address in the following DNS wildcard entries: + +~~~ +10-0-0-1.nip.io maps to 10.0.0.1 +app.10-0-0-1.nip.io maps to 10.0.0.1 +customer1.app.10-0-0-1.nip.io maps to 10.0.0.1 +customer2.app.10-0-0-1.nip.io maps to 10.0.0.1 +otherapp.10-0-0-1..nip.io maps to 10.0.0.1 + +NIP.IO maps ..nip.io to the corresponding , even 127-0-0-1.nip.io maps to 127.0.0.1 +~~~ + +## INSTALL + +TPD + +## LICENSE + +Apache2 http://www.apache.org/licenses/LICENSE-2.0 diff --git a/dist.sh b/dist.sh deleted file mode 100755 index 464920f..0000000 --- a/dist.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - - -abspath=$(which abspath) -if [ "$abspath" = "" ]; then - abspath="readlink -f" -fi - -me=$($abspath $0) -parent=$(dirname $me) -distname=$(basename $parent) - -build=$parent/build - -. $parent/dist.version - -[ -d "$build" ] && echo "Removing $build" && rm -rf "$build" - -scripts=$build/$distname/$version -mkdir -p "$scripts" - -cp $parent/src/* $scripts/ -chmod +x $scripts/*.py - -cd $build -tar zcf $distname-$version.tar.gz $distname diff --git a/dist.version b/dist.version deleted file mode 100644 index f7be363..0000000 --- a/dist.version +++ /dev/null @@ -1 +0,0 @@ -version=2 \ No newline at end of file diff --git a/src/backend.py b/src/nip.py old mode 100755 new mode 100644 similarity index 84% rename from src/backend.py rename to src/nip.py index 446a303..cae8a15 --- a/src/backend.py +++ b/src/nip.py @@ -1,4 +1,18 @@ #!/usr/bin/python +# +# Copyright 2017 René Moser +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import re @@ -47,7 +61,7 @@ class DynamicBackend: if not os.path.exists(fname): log('%s does not exist' % fname) sys.exit(1) - + fp = open(fname) config = ConfigParser.ConfigParser() config.readfp(fp) @@ -58,7 +72,7 @@ class DynamicBackend: self.domain = config.get('main', 'domain') self.ip_address = config.get('main', 'ipaddress') self.ttl = config.get('main', 'ttl') - + for entry in config.items('nameservers'): self.name_servers[entry[0]] = entry[1] @@ -109,8 +123,13 @@ class DynamicBackend: def handle_subdomains(self, qname): subdomain = qname[0:qname.find(self.domain)-1] + # Split foo.bar.10-0-0-1 in parts + subdomain_parts = subdomain.split('.') + + # Take the last part as this is the IP separated with dashes + ip_dashes = subdomain_parts[-1] + subparts = ip_dashes.split('-') - subparts = subdomain.split('.') if len(subparts) < 4: if DEBUG: log('subparts less than 4') self.handle_self(qname) @@ -152,8 +171,6 @@ class DynamicBackend: if __name__ == '__main__': - backend = DynamicBackend() backend.configure() backend.run() -