Ensure the mDNS mode is set every time network state changes

Eliminates (mostly) duplicate code
This commit is contained in:
Marc Brooks 2025-06-18 12:38:27 -05:00
parent a1ed28c676
commit 466bf40658
No known key found for this signature in database
GPG Key ID: 583A6AF2D6AE1DC6
1 changed files with 1 additions and 8 deletions

View File

@ -21,6 +21,7 @@ func networkStateChanged() {
// always restart mDNS when the network state changes // always restart mDNS when the network state changes
if mDNS != nil { if mDNS != nil {
_ = mDNS.SetListenOptions(config.NetworkConfig.GetMDNSMode())
_ = mDNS.SetLocalNames([]string{ _ = mDNS.SetLocalNames([]string{
networkState.GetHostname(), networkState.GetHostname(),
networkState.GetFQDN(), networkState.GetFQDN(),
@ -54,14 +55,6 @@ func initNetwork() error {
OnConfigChange: func(networkConfig *network.NetworkConfig) { OnConfigChange: func(networkConfig *network.NetworkConfig) {
config.NetworkConfig = networkConfig config.NetworkConfig = networkConfig
networkStateChanged() networkStateChanged()
if mDNS != nil {
_ = mDNS.SetListenOptions(networkConfig.GetMDNSMode())
_ = mDNS.SetLocalNames([]string{
networkState.GetHostname(),
networkState.GetFQDN(),
}, true)
}
}, },
}) })