Merge pull request #1 from a2ikm/master

Support dot-separated addresses
This commit is contained in:
René Moser 2018-05-13 09:20:59 +02:00 committed by GitHub
commit 2f7d368f2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -10,12 +10,14 @@ 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
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
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
customer1.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 <anything>.<IP Address with dashes>.nip.io to the corresponding <IP Address>, even 127-0-0-1.nip.io maps to 127.0.0.1
NIP.IO maps <anything>.<IP Address with dashes or dots>.nip.io to the corresponding <IP Address>, even 127-0-0-1.nip.io maps to 127.0.0.1
~~~
## INSTALL

View File

@ -131,20 +131,15 @@ 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('.')
match = re.findall('^(?:.+\.)?(\d{1,3}([-.])\d{1,3}\2\d{1,3}\2\d{1,3})$', subdomain)
# Take the last part as this is the IP separated with dashes
ip_dashes = subdomain_parts[-1]
subparts = ip_dashes.split('-')
if len(subparts) < 4:
if not match:
if DEBUG:
log('subparts less than 4')
log('%s is invalid format' % subdomain)
self.handle_self(qname)
return
ipaddress = subparts[-4:]
ipaddress = re.split('[-.]', match[0])
if DEBUG:
log('ip: %s' % ipaddress)
for part in ipaddress: