Browse Source

update deps

bdbai 3 years ago
parent
commit
d17ac3ab07

+ 2 - 2
Maple.App/Config/default.conf

@@ -1,8 +1,8 @@
 [General]
 # Log are for debug only
 loglevel = error
-# Do not remove tun-fd option
-tun-fd = 233
+# Do not remove tun option
+tun = auto
 dns-server = 223.5.5.5, 114.114.114.114
 
 [Proxy]

+ 2 - 2
Maple.App/Maple.App.vcxproj

@@ -14,7 +14,7 @@
     <AppContainerApplication>true</AppContainerApplication>
     <ApplicationType>Windows Store</ApplicationType>
     <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
-    <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.19041.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.22000.0</WindowsTargetPlatformVersion>
     <WindowsTargetPlatformMinVersion>10.0.15063.0</WindowsTargetPlatformMinVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -54,7 +54,7 @@
   </ItemGroup>
   <PropertyGroup Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
-    <PlatformToolset>v140</PlatformToolset>
+    <PlatformToolset>v143</PlatformToolset>
     <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
     <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
     <CharacterSet>Unicode</CharacterSet>

+ 11 - 30
Maple.App/Model/Netif.cpp

@@ -58,10 +58,7 @@ namespace winrt::Maple_App::implementation
         // Allocate a 15 KB buffer to start with.
         outBufLen = WORKING_BUFFER_SIZE;
         std::array<WCHAR, ADDR_BUFFER_SIZE> addrBuf{};
-        auto sniffed = Netif::SniffOutboundAddress();
-        if (sniffed == L"192.168.3.1") {
-            sniffed = {};
-        }
+        auto sniffed = Netif::SniffBestInterface();
 
         do {
 
@@ -116,7 +113,10 @@ namespace winrt::Maple_App::implementation
                         bufSize--;
                     }
                     hstring addr(addrBuf.data(), bufSize);
-                    hstring desc = addr == sniffed ? L"★" : L"";
+                    hstring desc{ L"" };
+                    if (friendlyName != L"Maple" && std::make_optional(pCurrAddresses->IfIndex) == sniffed) {
+                        desc = L"★";
+                    }
                     desc = desc + friendlyName + L" (" + addr + L")";
                     ret.emplace_back(winrt::make<Netif>(desc, addr));
                     pUnicast = pUnicast->Next;
@@ -130,38 +130,19 @@ namespace winrt::Maple_App::implementation
         return ret;
     }
 
-    hstring Netif::SniffOutboundAddress()
+    std::optional<DWORD> Netif::SniffBestInterface()
     {
-        const auto s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-        if (s == INVALID_SOCKET) {
-            return {};
-        }
-
         sockaddr saddr{};
         saddr.sa_family = AF_INET;
+        saddr.sa_data[0] = 0;
         saddr.sa_data[1] = 53;
         memset(&saddr.sa_data[2], 8, 4);
 
-        if (connect(s, &saddr, sizeof(saddr)) == SOCKET_ERROR) {
-            return {};
-        }
-
-        sockaddr_storage localAddr{};
-        int localAddrLen = sizeof(localAddr);
-
-        getsockname(s, (sockaddr*)&localAddr, &localAddrLen);
-        localAddr.__ss_pad1[0] = 0;
-        localAddr.__ss_pad1[1] = 0;
-
-        std::array<WCHAR, ADDR_BUFFER_SIZE> addrBuf{};
-        auto bufSize = static_cast<DWORD>(addrBuf.size());
-        if (FAILED(WSAAddressToStringW((LPSOCKADDR)&localAddr, localAddrLen, nullptr, addrBuf.data(), &bufSize))) {
-            return {};
-        }
-        if (bufSize > 0) {
-            bufSize--;
+        DWORD bestIfInd;
+        if (FAILED(GetBestInterfaceEx(&saddr, &bestIfInd))) {
+            return std::nullopt;
         }
-        return hstring(addrBuf.data(), bufSize);
+        return { bestIfInd };
     }
 
 }

+ 1 - 1
Maple.App/Model/Netif.h

@@ -13,7 +13,7 @@ namespace winrt::Maple_App::implementation
         hstring Addr();
 
         static std::vector<Maple_App::Netif> EnumerateInterfaces();
-        static hstring SniffOutboundAddress();
+        static std::optional<DWORD> SniffBestInterface();
 
     private:
         hstring m_desc;

+ 2 - 2
Maple.Task/Maple.Task.vcxproj

@@ -14,7 +14,7 @@
     <AppContainerApplication>true</AppContainerApplication>
     <ApplicationType>Windows Store</ApplicationType>
     <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
-    <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.19041.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.22000.0</WindowsTargetPlatformVersion>
     <WindowsTargetPlatformMinVersion>10.0.10240.0</WindowsTargetPlatformMinVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -54,7 +54,7 @@
   </ItemGroup>
   <PropertyGroup Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <PlatformToolset>v140</PlatformToolset>
+    <PlatformToolset>v143</PlatformToolset>
     <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
     <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
     <CharacterSet>Unicode</CharacterSet>

+ 2 - 1
Maple.Task/VpnPlugin.cpp

@@ -81,11 +81,12 @@ namespace winrt::Maple_Task::implementation
         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"");
+        const auto& cacheDir = appData.LocalCacheFolder().Path();
         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())
+            || !SetEnvironmentVariable(L"CACHE_LOCATION", cacheDir.data())
             ) {
             channel.TerminateConnection(L"Failed to set environment variables: " + winrt::to_hstring((uint32_t)GetLastError()));
             return;

+ 1 - 1
leaf

@@ -1 +1 @@
-Subproject commit da8030a6a74047090159ef4528c25edbbbab64eb
+Subproject commit a13db342e75419d1a4eae7afc57d766be01a1f6f