From 35072753d40368ef89cd983899f9a263c84ae7f4 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Fri, 30 Jun 2023 00:12:40 +0200 Subject: [PATCH] When replacing a domain name in the template: Domain -> FQDN. --- src/storage.cr | 2 +- src/storage/zone.cr | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/storage.cr b/src/storage.cr index 54e5638..5bad526 100644 --- a/src/storage.cr +++ b/src/storage.cr @@ -98,7 +98,7 @@ class DNSManager::Storage update_user_data user_data # Add the new zone in the database. - zones_by_domain.update_or_create default_zone.domain, default_zone + zones_by_domain.update_or_create domain, default_zone Response::Success.new end diff --git a/src/storage/zone.cr b/src/storage/zone.cr index f7e27eb..b012cbb 100644 --- a/src/storage/zone.cr +++ b/src/storage/zone.cr @@ -399,14 +399,16 @@ class DNSManager::Storage::Zone # When a new domain is recorded, we load a template which contains a placeholder domain. # `replace_domain` replaces this domain name by the real one in the different (preloaded) RR. + # Do not forget the last dot ('.') to get a fully qualified domain name (FQDN). def replace_domain(new_domain : String) @domain = new_domain + fqdn = "#{new_domain}." @resources.each do |rr| case rr when SOA - rr.name = domain + rr.name = fqdn when NS - rr.name = domain + rr.name = fqdn else Baguette::Log.debug "new domain, rr type #{rr.class} (nothing to do)" end