diff --git a/hal-core/src/se/hal/HalContext.java b/hal-core/src/se/hal/HalContext.java index 7263e5cd..9bb8a075 100644 --- a/hal-core/src/se/hal/HalContext.java +++ b/hal-core/src/se/hal/HalContext.java @@ -25,6 +25,7 @@ public class HalContext { public static final String CONFIG_HTTP_EXTERNAL_PORT = "hal_core.http_external_port"; public static final String CONFIG_HTTP_EXTERNAL_DOMAIN = "hal_core.http_external_domain"; public static final String CONFIG_HTTP_EXTERNAL_CERT = "hal_core.http_external_cert"; + public static final String CONFIG_DNS_LOCAL_DOMAIN = "hal_core.dns_local_domain"; public static final String CONFIG_MAP_BACKGROUND_IMAGE = "hal_core.map_bgimage"; public static final String RESOURCE_ROOT; diff --git a/hal-core/src/se/hal/daemon/HalMulticastDnsDaemon.java b/hal-core/src/se/hal/daemon/HalMulticastDnsDaemon.java index f989f050..fe4f486c 100644 --- a/hal-core/src/se/hal/daemon/HalMulticastDnsDaemon.java +++ b/hal-core/src/se/hal/daemon/HalMulticastDnsDaemon.java @@ -1,5 +1,6 @@ package se.hal.daemon; +import se.hal.HalContext; import se.hal.intf.HalDaemon; import zutil.log.LogUtil; import zutil.net.dns.MulticastDnsServer; @@ -10,6 +11,8 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.logging.Level; import java.util.logging.Logger; +import static se.hal.HalContext.CONFIG_DNS_LOCAL_DOMAIN; + public class HalMulticastDnsDaemon implements HalDaemon { private static final Logger logger = LogUtil.getLogger(); @@ -18,12 +21,20 @@ public class HalMulticastDnsDaemon implements HalDaemon { @Override public void initiate(ScheduledExecutorService executor) { - try { - server = new MulticastDnsServer(); - server.addEntry("hal.local", InetAddress.getLocalHost()); - server.start(); - } catch (IOException e) { - logger.log(Level.SEVERE, "Was unable to start mDNS Server.", e); + String localDomain = HalContext.getStringProperty(HalContext.CONFIG_DNS_LOCAL_DOMAIN, "hal.local"); + + if (!localDomain.isEmpty()) { + try { + logger.info("Initializing local mDNS server for domain: " + localDomain); + + server = new MulticastDnsServer(); + server.addEntry(localDomain, InetAddress.getLocalHost()); + server.start(); + } catch (IOException e) { + logger.log(Level.SEVERE, "Was unable to start mDNS Server.", e); + } + } else { + logger.info("Disabling local mDNS server."); } } diff --git a/hal.conf.example b/hal.conf.example index d34630a3..11a46620 100644 --- a/hal.conf.example +++ b/hal.conf.example @@ -12,6 +12,9 @@ hal_core.http_port=8080 #hal_core.http_external_port=8081 #hal_core.http_external_domain=example.com +# Set the local domain that hal will announce to the local network. Default value is hal.local leave empty to disable. +hal_core.dns_local_domain=hal.local| + # ------------------------------------------------------------------------ # Plugin configurations # ------------------------------------------------------------------------