Prechádzať zdrojové kódy

Set DNS assignment from profile

Fix #1 .
bdbai 4 rokov pred
rodič
commit
166638b837
3 zmenil súbory, kde vykonal 13 pridanie a 4 odobranie
  1. 11 2
      Maple.Task/VpnPlugin.cpp
  2. 1 1
      Maple.Task/leaf.h
  3. 1 1
      leaf

+ 11 - 2
Maple.Task/VpnPlugin.cpp

@@ -38,7 +38,6 @@ namespace winrt::Maple_Task::implementation
         // routeScope.Ipv4ExclusionRoutes(std::vector<VpnRoute>{
         //     VpnRoute(HostName{ L"172.25.0.0" }, 16)
         // });
-        VpnDomainNameAssignment dnsAssignment{};
 
         const auto outputStreamAbi = winrt::detach_abi(backTransport.OutputStream());
         StopLeaf();
@@ -83,12 +82,22 @@ namespace winrt::Maple_Task::implementation
         const auto& outNetifW = ApplicationData::Current().LocalSettings().Values().TryLookup(NETIF_SETTING_KEY).try_as<hstring>().value_or(L"");
         const auto& confPath = winrt::to_string(confPathW);
         const auto& outNetif = winrt::to_string(outNetifW);
-        m_leaf = run_leaf(confPath.data(), outNetif == "" ? nullptr : outNetif.data());
+        thread_local std::vector<HostName> dnsHosts{};
+        m_leaf = run_leaf(confPath.data(), outNetif == "" ? nullptr : outNetif.data(), [](const char* dns) {
+            dnsHosts.push_back(HostName{ to_hstring(dns) });
+            });
         if (m_leaf == nullptr) {
             channel.TerminateConnection(L"Error initializing Leaf runtime.\r\nPlease check your configuration file and default interface.");
             StopLeaf();
             return;
         }
+        VpnDomainNameAssignment dnsAssignment{};
+        dnsAssignment.DomainNameList().Append(VpnDomainNameInfo(
+            L".",
+            VpnDomainNameType::Suffix,
+            single_threaded_vector(std::move(dnsHosts)),
+            single_threaded_vector(std::vector<HostName>())));
+
         channel.StartWithMainTransport(
             std::vector<HostName> { HostName{ L"192.168.3.1" } },
             nullptr,

+ 1 - 1
Maple.Task/leaf.h

@@ -2,7 +2,7 @@
 
 extern "C" {
     typedef void Leaf;
-    Leaf* run_leaf(const char* path, const char* bind_host);
+    Leaf* run_leaf(const char* path, const char* bind_host, void on_dns(const char*));
     void stop_leaf(Leaf* leaf);
 
     typedef void NetStackHandle;

+ 1 - 1
leaf

@@ -1 +1 @@
-Subproject commit 34ab5939fed811ba0647f91170bfc69b3f39b6eb
+Subproject commit 2205519993df8a0edba4f9d57069dd55178c512b