-
Notifications
You must be signed in to change notification settings - Fork 709
Add network interface settings for mDNS/LLMNR #5520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
from dbus_fast import Variant | ||
|
||
from ....host.configuration import VlanConfig | ||
from ....host.const import InterfaceMethod, InterfaceType | ||
from ....host.const import InterfaceMethod, InterfaceType, MulticastDnsMode | ||
from ...const import MulticastDnsValue | ||
from .. import NetworkManager | ||
from . import ( | ||
CONF_ATTR_802_ETHERNET, | ||
|
@@ -134,6 +135,16 @@ def _get_ipv6_connection_settings(ipv6setting) -> dict: | |
return ipv6 | ||
|
||
|
||
def _map_mdns_setting(mode: MulticastDnsMode | None) -> int: | ||
mapping = { | ||
MulticastDnsMode.OFF: MulticastDnsValue.OFF, | ||
MulticastDnsMode.RESOLVE: MulticastDnsValue.RESOLVE, | ||
MulticastDnsMode.ANNOUNCE: MulticastDnsValue.ANNOUNCE, | ||
} | ||
|
||
return int(mapping[mode] if mode else MulticastDnsValue.ANNOUNCE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is actually also the mode -1 (default). Since we created the connections with the hardcoded value 2 (announce) so far, it probably hardly ever happens. I wonder if we actually should remove the hard coded announce (2) today and use default (-1) (the default is announce (2) too, at least on HAOS since home-assistant/operating-system#986, but it feels cleaner). Anyhow, this should be a separate PR, possible only once we start to officially deprecate old operating system versions. But ideally we introduce the default option here already, since Supervisor might also encounter such a connection setting today. I guess this should be straight forward, essentially add |
||
|
||
|
||
def get_connection_from_interface( | ||
interface: Interface, | ||
network_manager: NetworkManager, | ||
|
@@ -162,13 +173,16 @@ def get_connection_from_interface( | |
if not uuid: | ||
uuid = str(uuid4()) | ||
|
||
llmnr = _map_mdns_setting(interface.llmnr) | ||
mdns = _map_mdns_setting(interface.mdns) | ||
|
||
conn: dict[str, dict[str, Variant]] = { | ||
CONF_ATTR_CONNECTION: { | ||
CONF_ATTR_CONNECTION_ID: Variant("s", name), | ||
CONF_ATTR_CONNECTION_UUID: Variant("s", uuid), | ||
CONF_ATTR_CONNECTION_TYPE: Variant("s", iftype), | ||
CONF_ATTR_CONNECTION_LLMNR: Variant("i", 2), | ||
CONF_ATTR_CONNECTION_MDNS: Variant("i", 2), | ||
CONF_ATTR_CONNECTION_LLMNR: Variant("i", llmnr), | ||
CONF_ATTR_CONNECTION_MDNS: Variant("i", mdns), | ||
CONF_ATTR_CONNECTION_AUTOCONNECT: Variant("b", True), | ||
}, | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.