@@ -26,8 +26,13 @@ static wil::srwlock g_endpointsInUseLock;
2626static std::vector<GUID> g_endpointsInUse;
2727
2828NatNetworking::NatNetworking(
29- HCS_SYSTEM system, wsl::windows::common::hcs::unique_hcn_network&& network, GnsChannel&& gnsChannel, Config& config, wil::unique_socket&& dnsHvsocket) :
30- m_system(system), m_config(config), m_network(std::move(network)), m_gnsChannel(std::move(gnsChannel))
29+ HCS_SYSTEM system,
30+ wsl::windows::common::hcs::unique_hcn_network&& network,
31+ GnsChannel&& gnsChannel,
32+ Config& config,
33+ wil::unique_socket&& dnsHvsocket,
34+ LPCWSTR dnsOptions) :
35+ m_system(system), m_config(config), m_network(std::move(network)), m_dnsOptions(dnsOptions), m_gnsChannel(std::move(gnsChannel))
3136{
3237 m_connectivityTelemetryEnabled = config.EnableTelemetry && !WslTraceLoggingShouldDisableTelemetry();
3338
@@ -48,7 +53,7 @@ NatNetworking::NatNetworking(
4853 // prioritized means:
4954 // - can only set 3 DNS servers (Linux limitation)
5055 // - when there are multiple host connected interfaces, we need to use the DNS servers from the most-likely-to-be-used interface on the host
51- m_mirrorDnsInfo.emplace() ;
56+ m_useMirrorDnsSettings = true ;
5257 }
5358}
5459
@@ -337,7 +342,7 @@ void NatNetworking::Initialize()
337342 UpdateDns(endpointProperties.GatewayAddress.c_str());
338343
339344 // if using the shared access DNS proxy, ensure that the shared access service is allowed inbound UDP access.
340- if (!m_mirrorDnsInfo && !m_dnsTunnelingResolver)
345+ if (!m_useMirrorDnsSettings && !m_dnsTunnelingResolver)
341346 {
342347 // N.B. This rule works around a host OS issue that prevents the DNS proxy from working on older versions of Windows.
343348 ConfigureSharedAccessFirewallRule();
@@ -433,35 +438,22 @@ _Requires_lock_held_(m_lock)
433438void NatNetworking::UpdateDns(std::optional<PCWSTR> gatewayAddress) noexcept
434439try
435440{
436- if (!m_dnsTunnelingResolver && !m_mirrorDnsInfo && !gatewayAddress)
441+ if (!m_dnsTunnelingResolver && !m_useMirrorDnsSettings && !gatewayAddress)
437442 {
438443 return;
439444 }
440445
441446 networking::DnsInfo latestDnsSettings{};
442447
443- // true if the "domain" entry of /etc/resolv.conf should be configured
444- // Note: the "domain" entry allows a single DNS suffix to be configured
445- bool configureLinuxDomain = false;
446-
447448 // NAT mode with DNS tunneling
448449 if (m_dnsTunnelingResolver)
449450 {
450451 latestDnsSettings = HostDnsInfo::GetDnsTunnelingSettings(m_dnsTunnelingIpAddress);
451452 }
452453 // NAT mode without Shared Access DNS proxy
453- else if (m_mirrorDnsInfo )
454+ else if (m_useMirrorDnsSettings )
454455 {
455- m_mirrorDnsInfo->UpdateNetworkInformation();
456- const auto settings = m_mirrorDnsInfo->GetDnsSettings(DnsSettingsFlags::IncludeVpn);
457-
458- latestDnsSettings.Servers = std::move(settings.Servers);
459-
460- if (!settings.Domains.empty())
461- {
462- latestDnsSettings.Domains.emplace_back(std::move(settings.Domains.front()));
463- configureLinuxDomain = true;
464- }
456+ latestDnsSettings = HostDnsInfo::GetDnsSettings(DnsSettingsFlags::IncludeVpn);
465457 }
466458 // NAT mode with Shared Access DNS proxy
467459 else if (gatewayAddress)
@@ -472,11 +464,10 @@ try
472464
473465 if (latestDnsSettings != m_trackedDnsSettings)
474466 {
475- auto dnsNotification = BuildDnsNotification(latestDnsSettings, configureLinuxDomain );
467+ auto dnsNotification = BuildDnsNotification(latestDnsSettings, m_dnsOptions );
476468
477469 WSL_LOG(
478470 "NatNetworking::UpdateDns",
479- TraceLoggingValue(dnsNotification.Domain.c_str(), "domain"),
480471 TraceLoggingValue(dnsNotification.Options.c_str(), "options"),
481472 TraceLoggingValue(dnsNotification.Search.c_str(), "search"),
482473 TraceLoggingValue(dnsNotification.ServerList.c_str(), "serverList"));
0 commit comments