Allow configuration of dns listener host/port (#74)

* Allow configuration of dns listener host/port

* Make DNS listen host/port configuration HUP-able
This commit is contained in:
Robin B
2019-12-12 02:42:55 +01:00
committed by Nathan Brown
parent 5c99ea26c9
commit a086d60edc
3 changed files with 39 additions and 14 deletions

13
main.go
View File

@ -204,7 +204,6 @@ func Main(configPath string, configTest bool, buildVersion string) {
lighthouseHosts[i] = ip2int(ip)
}
serveDns := config.GetBool("lighthouse.serve_dns", false)
lightHouse := NewLightHouse(
amLighthouse,
ip2int(tunCidr.IP),
@ -216,11 +215,6 @@ func Main(configPath string, configTest bool, buildVersion string) {
punchBack,
)
if amLighthouse && serveDns {
l.Debugln("Starting dns server")
go dnsMain(hostMap)
}
//TODO: Move all of this inside functions in lighthouse.go
for k, v := range config.GetMap("static_host_map", map[interface{}]interface{}{}) {
vpnIp := net.ParseIP(fmt.Sprintf("%v", k))
@ -264,6 +258,7 @@ func Main(configPath string, configTest bool, buildVersion string) {
//handshakeMACKey := config.GetString("handshake_mac.key", "")
//handshakeAcceptedMACKeys := config.GetStringSlice("handshake_mac.accepted_keys", []string{})
serveDns := config.GetBool("lighthouse.serve_dns", false)
checkInterval := config.GetInt("timers.connection_alive_interval", 5)
pendingDeletionInterval := config.GetInt("timers.pending_deletion_interval", 10)
ifConfig := &InterfaceConfig{
@ -313,6 +308,12 @@ func Main(configPath string, configTest bool, buildVersion string) {
attachCommands(ssh, hostMap, handshakeManager.pendingHostMap, lightHouse, ifce)
ifce.Run(config.GetInt("tun.routines", 1), udpQueues, buildVersion)
// Start DNS server last to allow using the nebula IP as lighthouse.dns.host
if amLighthouse && serveDns {
l.Debugln("Starting dns server")
go dnsMain(hostMap, config)
}
// Just sit here and be friendly, main thread.
shutdownBlock(ifce)
}