Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 4 additions & 9 deletions src/nip.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,15 @@ def handle_self(self, name):

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:
Expand Down