Skip to content

Commit

Permalink
Update DNS plug-in on network change
Browse files Browse the repository at this point in the history
Restart the DNS plug-in when the primary network changes network
changes. This makes sure any potential host OS DNS configuration
changes get picked up by the DNS plug-in as well.
  • Loading branch information
agners committed Oct 9, 2024
1 parent e2b25fe commit f652875
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions supervisor/host/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
from ..dbus.const import (
DBUS_ATTR_CONNECTION_ENABLED,
DBUS_ATTR_CONNECTIVITY,
DBUS_ATTR_PRIMARY_CONNECTION,
DBUS_IFACE_NM,
DBUS_OBJECT_BASE,
DBUS_SIGNAL_NM_CONNECTION_ACTIVE_CHANGED,
ConnectionStateType,
ConnectivityState,
Expand Down Expand Up @@ -148,6 +150,15 @@ async def _check_connectivity_changed(
connectivity_check: bool | None = changed.get(DBUS_ATTR_CONNECTION_ENABLED)
connectivity: bool | None = changed.get(DBUS_ATTR_CONNECTIVITY)

# This potentially updated the DNS configuration. Make sure the DNS plug-in
# picks up the latest settings.
if (
DBUS_ATTR_PRIMARY_CONNECTION in changed
and changed[DBUS_ATTR_PRIMARY_CONNECTION]
and changed[DBUS_ATTR_PRIMARY_CONNECTION] != DBUS_OBJECT_BASE
):
await self.sys_plugins.dns.restart()

if (
connectivity_check is True
or DBUS_ATTR_CONNECTION_ENABLED in invalidated
Expand Down

0 comments on commit f652875

Please sign in to comment.