Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nodeid and use hostname as cname #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
a subdomain which contains all the Freifunk Router of a Freifunk community so that they are
accesible with a name.

It uses a http request to get a meshviewer.json, extracts all the valid hostnames
It uses a http request to get a meshviewer.json, extracts all the valid hostnames and nodeids
and outputs a zonefile for a "node domain".

## Installation
Expand Down Expand Up @@ -52,4 +52,4 @@ cd $DIR

cp nodes.ffrn.de.zone /etc/bind/zones/
/usr/sbin/rndc reload nodes.ffrn.de > /dev/null
```
```
16 changes: 12 additions & 4 deletions generateZonefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@


class FFNode:
def __init__(self, hostname, addresses, firstseen):
def __init__(self, hostname, nodeid, addresses, firstseen):
self.hostname = hostname
self.nodeid = nodeid
self.addresses = addresses
self.firstseen = firstseen

Expand Down Expand Up @@ -70,8 +71,13 @@ def main():
hostname_list = []
for node in nodes:
for address in node.addresses:
lines.append(LINE_TPL.format(name=node.hostname, type="AAAA", data=address))
hostname_list.append(node.hostname)
lines.append(LINE_TPL.format(name=node.nodeid, type="AAAA", data=address))

if(node.hostname != node.nodeid):
lines.append(LINE_TPL.format(name=node.hostname, type="CNAME", data=node.nodeid))
hostname_list.append(node.hostname)

hostname_list.append(node.nodeid)

# get a serial number
serial = int(time.time())
Expand Down Expand Up @@ -153,7 +159,9 @@ def generate_node_hostname(node):
warning("not allowed: \t" + node["hostnameLower"] + " " + node["firstseen"])
return

return FFNode(node["hostnameLower"], (addresses_gua if addresses_gua else addresses_ula ), node["firstseen"])
return FFNode(node["hostnameLower"], node["node_id"], (addresses_gua if addresses_gua else addresses_ula ), node["firstseen"])




if __name__ == "__main__":
Expand Down