فهرست منبع

Set bind addr from env

bdbai 4 سال پیش
والد
کامیت
fa4f37f61d
3فایلهای تغییر یافته به همراه14 افزوده شده و 9 حذف شده
  1. 12 7
      Maple.Task/VpnPlugin.cpp
  2. 1 1
      Maple.Task/leaf.h
  3. 1 1
      leaf

+ 12 - 7
Maple.Task/VpnPlugin.cpp

@@ -77,19 +77,24 @@ namespace winrt::Maple_Task::implementation
             return;
         }
 
-        const auto& configFolderPath = Windows::Storage::ApplicationData::Current().LocalFolder().CreateFolderAsync(L"config", CreationCollisionOption::OpenIfExists).get().Path();
-        if (!SetEnvironmentVariable(L"ASSET_LOCATION", configFolderPath.data())) {
-            channel.TerminateConnection(L"Failed to set asset location: " + winrt::to_hstring((uint32_t)GetLastError()));
+        const auto& appData = ApplicationData::Current();
+        const auto& configFolderPath = appData.LocalFolder().CreateFolderAsync(L"config", CreationCollisionOption::OpenIfExists).get().Path();
+        const auto& localProperties = appData.LocalSettings().Values();
+        const auto& outNetif = localProperties.TryLookup(NETIF_SETTING_KEY).try_as<hstring>().value_or(L"");
+        if (
+            !SetEnvironmentVariable(L"ASSET_LOCATION", configFolderPath.data())
+            || !SetEnvironmentVariable(L"LOG_NO_COLOR", L"true")
+            || !SetEnvironmentVariable(L"ENABLE_IPV6", L"true")
+            || !SetEnvironmentVariable(L"OUTBOUND_INTERFACE", outNetif.data())
+            ) {
+            channel.TerminateConnection(L"Failed to set environment variables: " + winrt::to_hstring((uint32_t)GetLastError()));
             return;
         }
 
-        const auto& localProperties = ApplicationData::Current().LocalSettings().Values();
         const auto& confPathW = localProperties.TryLookup(CONFIG_PATH_SETTING_KEY).try_as<hstring>().value_or(L"");
-        const auto& outNetifW = localProperties.TryLookup(NETIF_SETTING_KEY).try_as<hstring>().value_or(L"");
         const auto& confPath = winrt::to_string(confPathW);
-        const auto& outNetif = winrt::to_string(outNetifW);
         thread_local std::vector<HostName> dnsHosts{};
-        m_leaf = run_leaf(confPath.data(), outNetif == "" ? nullptr : outNetif.data(), [](const char* dns) {
+        m_leaf = run_leaf(confPath.data(), [](const char* dns) {
             dnsHosts.push_back(HostName{ to_hstring(dns) });
             });
         if (m_leaf == 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, void on_dns(const char*));
+    Leaf* run_leaf(const char* path, void on_dns(const char*));
     void stop_leaf(Leaf* leaf);
 
     typedef void NetStackHandle;

+ 1 - 1
leaf

@@ -1 +1 @@
-Subproject commit e1093528ea236d991409286e9073572b8baab4c6
+Subproject commit a7a16741e32e395823897b2d2c8c9bcfc4223f5e