Skip to content

Commit e0e403d

Browse files
committed
Fix DNS discovery: publish _config TXT under NS hostname, not just node ID
The server node ID fix (v0.6.4) changed the _config TXT record from _config.ns1.lemonade-nexus.io to _config.server-0edf40003dfe0f7a. Clients query _config.<ns_hostname> so they got NXDOMAIN. Now publishes under BOTH the NS prefix (ns1) and the node ID.
1 parent 432e0e3 commit e0e403d

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

projects/LemonadeNexus/src/main.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,17 +398,34 @@ int main(int argc, char* argv[]) {
398398

399399
acme.set_dns_service(&dns);
400400

401-
// Publish _config TXT record (gossip-synced)
401+
// Publish _config TXT records (gossip-synced)
402+
// The NS hostname (e.g. "ns1") is what clients use for DNS discovery.
403+
// Also publish under the server node ID for gossip-based discovery.
402404
{
403-
std::string config_id = nexus::core::resolve_server_node_id(storage);
404-
if (config_id.empty() && !config.server_hostname.empty()) {
405-
config_id = config.server_hostname;
405+
std::string config_fqdn = nexus::core::build_server_fqdn(
406+
config.server_hostname, config.dns_base_domain);
407+
408+
// Determine the NS hostname prefix (e.g. "ns1" from "ns1.lemonade-nexus.io")
409+
std::string ns_prefix;
410+
std::string ns_fqdn = config.dns_ns_hostname;
411+
if (ns_fqdn.empty() && !config.server_hostname.empty()) {
412+
ns_prefix = config.server_hostname;
413+
} else if (!ns_fqdn.empty()) {
414+
auto dot = ns_fqdn.find('.');
415+
ns_prefix = (dot != std::string::npos) ? ns_fqdn.substr(0, dot) : ns_fqdn;
406416
}
407-
if (!config_id.empty()) {
408-
std::string config_fqdn = nexus::core::build_server_fqdn(
409-
config.server_hostname, config.dns_base_domain);
410-
dns.publish_port_config(config_id, config_fqdn);
411-
spdlog::info("DNS: published _config TXT for {} (host={})", config_id, config_fqdn);
417+
418+
// Publish under NS hostname prefix (for client DNS discovery: _config.ns1.domain)
419+
if (!ns_prefix.empty()) {
420+
dns.publish_port_config(ns_prefix, config_fqdn);
421+
spdlog::info("DNS: published _config TXT for {} (host={})", ns_prefix, config_fqdn);
422+
}
423+
424+
// Also publish under server node ID (for gossip-based server discovery)
425+
std::string node_id = nexus::core::resolve_server_node_id(storage);
426+
if (!node_id.empty() && node_id != ns_prefix) {
427+
dns.publish_port_config(node_id, config_fqdn);
428+
spdlog::info("DNS: published _config TXT for {} (host={})", node_id, config_fqdn);
412429
}
413430
}
414431

0 commit comments

Comments
 (0)