Added ability to disable local mDNS server
This commit is contained in:
parent
4d1922d088
commit
dc200294be
3 changed files with 21 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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|<empty>
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Plugin configurations
|
||||
# ------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue