Skip to content

Commit

Permalink
fixup! wip: use knot instead of pdns
Browse files Browse the repository at this point in the history
  • Loading branch information
peterthomassen committed Jan 4, 2024
1 parent 8de9b2b commit a45c6e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
3 changes: 2 additions & 1 deletion ns/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ echo mgroup from eth2 group 239.1.2.3 > /etc/smcroute.conf
/usr/sbin/smcroute -d

# Render configuration
export _NPROC=$(nproc)
envsubst < /etc/knot/knot.conf.var > /etc/knot/knot.conf

ls -lah /config/
Expand All @@ -20,5 +19,7 @@ ls -lah /config/
#[ -n "$DESEC_NS_SIGNALING_DOMAIN_ZONE_PRIVATE_KEY_B64" ] && \
# su pdns -s /bin/bash -c /usr/bin/local/signaling_domain_zone.sh

# TODO Consider XDP, https://www.knot-dns.cz/docs/3.3/html/operation.html#pre-requisites

# Start pdns for production
exec knotd -c /etc/knot/knot.conf
39 changes: 14 additions & 25 deletions replicator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,45 +108,34 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self.send(libknot.control.KnotCtlType.END)
self.close()

def send_receive_block(self, *args, **kwargs):
super().send_block(*args, **kwargs)
return super().receive_block()

def get_local_zone_serials(self) -> Dict[str, int]:
with self.KnotCtl() as ctl:
ctl.send_block(cmd="zone-status")
resp = ctl.receive_block()
resp = ctl.send_receive_block(cmd="zone-status")
return {name: int(values['serial']) for name, values in resp.items()}

def add_zone(self, name: str) -> None:
with self.KnotCtl() as ctl:
try:
ctl.send_block(cmd="conf-begin", zone=name)
resp = ctl.receive_block()
ctl.send_block(cmd="conf-set", section="zone", item=f"domain", data=name)
resp = ctl.receive_block()
ctl.send_block(cmd="conf-set", section="zone", item=f"master", data="nsmaster")
resp = ctl.receive_block()
ctl.send_block(cmd="conf-commit")
resp = ctl.receive_block()
ctl.send_block(cmd="conf-read", section="zone", item="domain", flags="e")
resp = ctl.receive_block()
print(json.dumps(resp, indent=4))
ctl.send_receive_block(cmd="conf-begin", zone=name)
ctl.send_receive_block(cmd="conf-set", section="zone", item="domain", data=name)
ctl.send_receive_block(cmd="conf-set", section="zone", item="master", data="nsmaster")
ctl.send_receive_block(cmd="conf-commit")
except libknot.control.KnotCtlErrorRemote:
ctl.send_block(cmd="conf-abort", zone=name)
resp = ctl.receive_block()
ctl.send_receive_block(cmd="conf-abort", zone=name)

def axfr(self, name: str) -> None:
with self.KnotCtl() as ctl:
ctl.send_block(cmd="zone-retransfer", zone=name)
resp = ctl.receive_block()
ctl.send_receive_block(cmd="zone-retransfer", zone=name)

def remove_zone(self, name: str) -> None:
with self.KnotCtl() as ctl:
ctl.send_block(cmd="conf-begin", zone=name)
resp = ctl.receive_block()
ctl.send_block(cmd="conf-unset", section="zone", item=f"domain", data=name)
resp = ctl.receive_block()
ctl.send_block(cmd="conf-commit")
resp = ctl.receive_block()
ctl.send_block(cmd="conf-read", section="zone", item="domain", flags="e")
resp = ctl.receive_block()
ctl.send_receive_block(cmd="conf-begin", zone=name)
ctl.send_receive_block(cmd="conf-unset", section="zone", item="domain", data=name)
ctl.send_receive_block(cmd="conf-commit")


def query_serial(zone, server):
Expand Down

0 comments on commit a45c6e0

Please sign in to comment.