From df344230526ef2e805b36816d0b4fbef151c2203 Mon Sep 17 00:00:00 2001 From: AirVPN Date: Tue, 10 Dec 2024 14:36:47 +0100 Subject: [PATCH] 2.24.5 --- .../bundle/eddie-ui/DEBIAN/control | 2 +- .../bundle/eddie-ui2/DEBIAN/control | 2 +- repository/windows_portable/build.bat | 2 +- src/App.CLI.MacOS.Elevated/src/impl.cpp | 9 +- src/App.CLI.Windows.Elevated/include/impl.h | 2 + src/App.CLI.Windows.Elevated/src/impl.cpp | 120 ++++++++++++++++++ src/Lib.CLI.Elevated/include/ibase.h | 2 +- src/Lib.CLI.Elevated/src/ibase.cpp | 12 +- src/Lib.Core/Constants.cs | 6 +- src/Lib.Core/Elevated/ISocket.cs | 2 +- src/Lib.Core/Jobs/Discover.cs | 3 +- src/Lib.Core/ProfileOptions.cs | 2 +- src/Lib.Platform.MacOS.Native/src/lib.cpp | 6 +- src/Lib.Platform.MacOS/Platform.cs | 11 +- 14 files changed, 163 insertions(+), 18 deletions(-) diff --git a/repository/linux_debian/bundle/eddie-ui/DEBIAN/control b/repository/linux_debian/bundle/eddie-ui/DEBIAN/control index fe5a5abc..0ae4db3e 100644 --- a/repository/linux_debian/bundle/eddie-ui/DEBIAN/control +++ b/repository/linux_debian/bundle/eddie-ui/DEBIAN/control @@ -5,7 +5,7 @@ Maintainer: Eddie Priority: optional Architecture: {@architecture} Installed-Size: 8192 -Depends: libc6 (>= 2.3.2), policykit-1, curl, libnotify-bin, openvpn, stunnel4, libcurl4, libsecret-tools, libayatana-appindicator3-1 +Depends: libc6 (>= 2.3.2), pkexec | policykit-1, curl, libnotify-bin, openvpn, stunnel4, libcurl4, libsecret-tools, libayatana-appindicator3-1 Breaks: airvpn (<< 2.14.4) Replaces: airvpn (<< 2.14.4) Homepage: https://eddie.website/ diff --git a/repository/linux_debian/bundle/eddie-ui2/DEBIAN/control b/repository/linux_debian/bundle/eddie-ui2/DEBIAN/control index f075003e..577c6c36 100644 --- a/repository/linux_debian/bundle/eddie-ui2/DEBIAN/control +++ b/repository/linux_debian/bundle/eddie-ui2/DEBIAN/control @@ -5,7 +5,7 @@ Maintainer: Eddie Priority: optional Architecture: {@architecture} Installed-Size: 8192 -Depends: libc6 (>= 2.3.2), policykit-1, curl, libnotify-bin, openvpn, stunnel4, libcurl4, libsecret-tools, libayatana-appindicator3-1, mono-runtime-common +Depends: libc6 (>= 2.3.2), pkexec | policykit-1, curl, libnotify-bin, openvpn, stunnel4, libcurl4, libsecret-tools, libayatana-appindicator3-1, mono-runtime-common Breaks: airvpn (<< 2.14.4) Replaces: airvpn (<< 2.14.4) Homepage: https://eddie.website/ diff --git a/repository/windows_portable/build.bat b/repository/windows_portable/build.bat index 2de8454c..f4c303cf 100644 --- a/repository/windows_portable/build.bat +++ b/repository/windows_portable/build.bat @@ -53,7 +53,7 @@ mkdir !VARTARGETDIR! copy !VARSCRIPTDIR!\portable.txt !VARTARGETDIR! IF "!VARPROJECT!"=="cli" ( - cd "!VARSCRIPTDIR!\..\..\src\App.CLI.Windows\" + cd /d "!VARSCRIPTDIR!\..\..\src\App.CLI.Windows\" dotnet publish App.CLI.Windows.net8.csproj --configuration Release --runtime !VARRID! --self-contained true -p:PublishTrimmed=true -p:EnableCompressionInSingleFile=true copy !VARSCRIPTDIR!\..\..\src\App.CLI.Windows\bin\!VARCONFIG!\net8.0\!VARRID!\publish\* !VARTARGETDIR! || goto :error copy !VARSCRIPTDIR!\..\..\src\App.CLI.Windows\bin\!VARCONFIG!\net8.0\!VARRID!\Eddie-CLI-Elevated.exe !VARTARGETDIR! || goto :error diff --git a/src/App.CLI.MacOS.Elevated/src/impl.cpp b/src/App.CLI.MacOS.Elevated/src/impl.cpp index d77c7b2f..4a968b03 100644 --- a/src/App.CLI.MacOS.Elevated/src/impl.cpp +++ b/src/App.CLI.MacOS.Elevated/src/impl.cpp @@ -430,10 +430,13 @@ void Impl::Do(const std::string& commandId, const std::string& command, std::map } else if (command == "wireguard-version") { - std::string wgPath = FsLocateExecutable("wg"); // Expected in macOS .app bundle + std::string wgPath = FsLocateExecutable("wg", false, true); // Expected in macOS .app bundle std::string version = ExecEx1(wgPath, "version").out; - version = StringReplaceAll(version, "wireguard-tools v", ""); - version = StringReplaceAll(version, " - https://git.zx2c4.com/wireguard-tools/", ""); + version = StringReplaceAll(version, "wireguard-tools", ""); + version = StringTrim(version, "v "); + size_t afterPos = version.find(' '); + if(afterPos != std::string::npos) + version = version.substr(0, afterPos); ReplyCommand(commandId, version); } else if (command == "wireguard") diff --git a/src/App.CLI.Windows.Elevated/include/impl.h b/src/App.CLI.Windows.Elevated/include/impl.h index a93186e8..c478c645 100644 --- a/src/App.CLI.Windows.Elevated/include/impl.h +++ b/src/App.CLI.Windows.Elevated/include/impl.h @@ -53,5 +53,7 @@ class Impl :public IWindows bool WfpRemovePending(const std::string& filterName, const std::string& xml); const char* WfpGetLastError(); DWORD WfpGetLastErrorCode(); + + void CleanupCompatibility(); }; diff --git a/src/App.CLI.Windows.Elevated/src/impl.cpp b/src/App.CLI.Windows.Elevated/src/impl.cpp index c1e90fd4..4d990165 100644 --- a/src/App.CLI.Windows.Elevated/src/impl.cpp +++ b/src/App.CLI.Windows.Elevated/src/impl.cpp @@ -80,6 +80,8 @@ int Impl::Main() ThrowException("Error in sockets initialization"); } + // CleanupCompatibility(); + int result = IWindows::Main(); WSACleanup(); @@ -1074,4 +1076,122 @@ const char* Impl::WfpGetLastError() DWORD Impl::WfpGetLastErrorCode() { return m_wfpLastErrorCode; +} + +#include // Necessario per SHGetKnownFolderPath + +// Note: not yet used +void Impl::CleanupCompatibility() +{ + // Old NSIS Start Menu Folder + if (true) + { + HKEY hKey; + wchar_t bufferName[4096]; + DWORD bufferNameSize = sizeof(bufferName); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\WOW6432Node\\AirVPN", 0, KEY_READ, &hKey) == ERROR_SUCCESS) + { + bool result = (RegQueryValueEx(hKey, L"Start Menu Folder", NULL, NULL, reinterpret_cast(bufferName), &bufferNameSize) == ERROR_SUCCESS); + RegCloseKey(hKey); + if (result) + { + PWSTR path = NULL; + HRESULT hr = SHGetKnownFolderPath(FOLDERID_CommonPrograms, 0, NULL, &path); + if (SUCCEEDED(hr)) + { + std::wstring commonProgramsPath(path); + commonProgramsPath += L"\\"; + commonProgramsPath += std::wstring(bufferName); + CoTaskMemFree(path); + + WIN32_FIND_DATA fd; + HANDLE h = FindFirstFile((commonProgramsPath + L"\\*.lnk").c_str(), &fd); + if (h != INVALID_HANDLE_VALUE) + { + do + { + DeleteFile((commonProgramsPath + L"\\" + fd.cFileName).c_str()); + } while (FindNextFile(h, &fd)); + FindClose(h); + } + h = FindFirstFile((commonProgramsPath + L"\\*").c_str(), &fd); + if (h != INVALID_HANDLE_VALUE) + { + bool empty = true; + do + { + if (wcscmp(fd.cFileName, L".") && wcscmp(fd.cFileName, L"..")) + { + empty = false; + break; + } + } while (FindNextFile(h, &fd)); + FindClose(h); + if (empty) + RemoveDirectory(commonProgramsPath.c_str()); + } + } + } + } + } + + // Old NSIS installer entry + if (true) + { + HKEY hKey; + wchar_t buffer[4096]; + DWORD bufferSize = sizeof(buffer); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AirVPN", 0, KEY_READ, &hKey) == ERROR_SUCCESS) + { + bool result = (RegQueryValueEx(hKey, L"UninstallString", NULL, NULL, reinterpret_cast(buffer), &bufferSize) == ERROR_SUCCESS); + RegCloseKey(hKey); + if (result) + { + // Delete NSIS uninstall.exe + std::wstring uninstallerExe(buffer); + std::string uninstallerExeUtf8 = StringWStringToUTF8(uninstallerExe); + uninstallerExeUtf8 = StringTrim(uninstallerExeUtf8, "\""); + FsFileDelete(uninstallerExeUtf8); + + // Delete Program Entry + RegDeleteKeyEx( + HKEY_LOCAL_MACHINE, + L"SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AirVPN", + KEY_WOW64_32KEY, + 0 + ); + } + } + } + + // Old NSIS RegKey + if (true) + { + RegDeleteKeyEx( + HKEY_LOCAL_MACHINE, + L"SOFTWARE\\WOW6432Node\\AirVPN", + KEY_WOW64_32KEY, + 0 + ); + } + + // Old NSIS directory + if (false) + { + HKEY hKey; + wchar_t buffer[4096]; + DWORD bufferSize = sizeof(buffer); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\WOW6432Node\\AirVPN", 0, KEY_READ, &hKey) == ERROR_SUCCESS) + { + bool result = (RegQueryValueEx(hKey, L"", NULL, NULL, reinterpret_cast(buffer), &bufferSize) == ERROR_SUCCESS); + RegCloseKey(hKey); + if (result) + { + // TODO + } + } + } } \ No newline at end of file diff --git a/src/Lib.CLI.Elevated/include/ibase.h b/src/Lib.CLI.Elevated/include/ibase.h index dab6c6af..e06635db 100644 --- a/src/Lib.CLI.Elevated/include/ibase.h +++ b/src/Lib.CLI.Elevated/include/ibase.h @@ -70,7 +70,7 @@ class IBase { private: std::string m_elevatedVersion = "v1378"; - int m_elevatedPortDefault = 9349; + int m_elevatedPortDefault = 9350; std::string m_session_key; std::mutex m_mutex_inout; diff --git a/src/Lib.CLI.Elevated/src/ibase.cpp b/src/Lib.CLI.Elevated/src/ibase.cpp index a5eb244f..f0129b19 100644 --- a/src/Lib.CLI.Elevated/src/ibase.cpp +++ b/src/Lib.CLI.Elevated/src/ibase.cpp @@ -93,6 +93,17 @@ void IBase::MainDo(const std::string& commandId, const std::string& command, std if (clientVersion != m_elevatedVersion) ThrowException("Unexpected version, elevated: " + m_elevatedVersion + ", client: " + clientVersion); + if (params.find("path") != params.end()) // 2.24.5 + { + if (GetProcessPathCurrentDir() != params["path"]) + { + // This occur for example if Eddie in installed and service active, but another portable is running. + // Basically this is not a problem, if ElevatedVersion above match. + // But Security Hashes Checks will fail. + ThrowException("Unexpected path mismatch, elevated: " + GetProcessPathCurrentDir() + ", client: " + params["path"]); + } + } + m_session_key = params["key"]; } else @@ -998,7 +1009,6 @@ std::string IBase::FsLocateExecutable(const std::string& name, const bool throwE return ""; } - // -------------------------- // Utils string // -------------------------- diff --git a/src/Lib.Core/Constants.cs b/src/Lib.Core/Constants.cs index e6806fb7..284498e5 100644 --- a/src/Lib.Core/Constants.cs +++ b/src/Lib.Core/Constants.cs @@ -29,8 +29,8 @@ public static class Constants public static byte[] NotSecretPayload = Encoding.UTF8.GetBytes("4af85e84255b077ad890dba297e811b7d016add1"); public static string PasswordIfEmpty = "e6552ddf3ac5c8755a82870d91273a63eab0da1e"; public static string Thanks = "Clodo, PJ, reiandrea, ProMIND, Berserker, OpenSourcerer, zhang888, LZ1, giganerd, Uncle Hunto, go558a83nk, sheivoko, NaDre, pfSense_fan, x0wllaar, cmaves"; - public static int VersionInt = 294; - public static string VersionDesc = "2.24.4"; // Used by deploy system also to generate filenames + public static int VersionInt = 295; + public static string VersionDesc = "2.24.5"; // Used by deploy system also to generate filenames public static bool VersionBeta = false; public static string Domain = "eddie.website"; public static string WebSite = "https://eddie.website"; @@ -39,7 +39,7 @@ public static class Constants public static string DnsVpn = "10.4.0.1"; // < 2.9, TOCLEAN public static DateTime dateForPastChecking = new DateTime(2014, 08, 26); public static string ElevatedVersionExpected = "v1378"; - public static int ElevatedServicePort = 9349; + public static int ElevatedServicePort = 9350; // Feature activation at compilation-time public static bool OurRoutesInWin7 = true; diff --git a/src/Lib.Core/Elevated/ISocket.cs b/src/Lib.Core/Elevated/ISocket.cs index 5b246141..bcdce7bd 100644 --- a/src/Lib.Core/Elevated/ISocket.cs +++ b/src/Lib.Core/Elevated/ISocket.cs @@ -71,7 +71,7 @@ protected string Connect(int port) m_sessionKey = RandomGenerator.GetHash(); - DoCommandSync("session-key", "key", m_sessionKey, "version", Constants.ElevatedVersionExpected); + DoCommandSync("session-key", "key", m_sessionKey, "version", Constants.ElevatedVersionExpected, "path", Platform.Instance.GetApplicationPath()); if (m_failedReason != "") return m_failedReason; diff --git a/src/Lib.Core/Jobs/Discover.cs b/src/Lib.Core/Jobs/Discover.cs index 1633d7f5..0f6f9ac8 100644 --- a/src/Lib.Core/Jobs/Discover.cs +++ b/src/Lib.Core/Jobs/Discover.cs @@ -149,7 +149,8 @@ private Json DiscoverIpData(string ip, string layer) httpRequest.Url = url; httpRequest.IpLayer = layer; - string json = Engine.Instance.FetchUrl(httpRequest).GetBody(); + HttpResponse httpResponse = Engine.Instance.FetchUrl(httpRequest); + string json = httpResponse.GetBody(); Json jDoc = Json.Parse(json); NormalizeServiceResponse(jDoc); diff --git a/src/Lib.Core/ProfileOptions.cs b/src/Lib.Core/ProfileOptions.cs index 15c776b4..ca9124b2 100644 --- a/src/Lib.Core/ProfileOptions.cs +++ b/src/Lib.Core/ProfileOptions.cs @@ -439,7 +439,7 @@ public void EnsureDefaults() SetDefault("areas.allowlist", "text", "", LanguageManager.GetText(LanguageItems.ManOptionAreasAllowlist)); SetDefault("areas.denylist", "text", "", LanguageManager.GetText(LanguageItems.ManOptionAreasDenylist)); - SetDefault("discover.ip_webservice.list", "text", "https://ipleak.net/json/{@ip};https://freegeoip.net/json/{@ip};http://ip-api.com/json/{@ip}", LanguageManager.GetText(LanguageItems.ManOptionDiscoverIpWebserviceList)); + SetDefault("discover.ip_webservice.list", "text", "https://eddie.website/ipinfo/{@ip};https://ipleak.net/json/{@ip};http://ip-api.com/json/{@ip}", LanguageManager.GetText(LanguageItems.ManOptionDiscoverIpWebserviceList)); SetDefaultInt("discover.interval", 60 * 60 * 24, LanguageManager.GetText(LanguageItems.ManOptionDiscoverInterval)); SetDefaultBool("discover.exit", true, LanguageManager.GetText(LanguageItems.ManOptionDiscoverExit)); diff --git a/src/Lib.Platform.MacOS.Native/src/lib.cpp b/src/Lib.Platform.MacOS.Native/src/lib.cpp index a3dc16c8..ba34eb19 100644 --- a/src/Lib.Platform.MacOS.Native/src/lib.cpp +++ b/src/Lib.Platform.MacOS.Native/src/lib.cpp @@ -193,9 +193,13 @@ extern "C" { //totalibytes += if2m->ifm_data.ifi_ibytes; //totalobytes += if2m->ifm_data.ifi_obytes; + char ifname[IF_NAMESIZE]; + if_indextoname(if2m->ifm_index, ifname); + if (nRecords > 0) jsonStr += ","; - jsonStr += "{ \"id\":" + std::to_string(if2m->ifm_index) + ",\"rcv\":" + std::to_string(if2m->ifm_data.ifi_ibytes) + ",\"snd\":" + std::to_string(if2m->ifm_data.ifi_obytes) + " }"; + jsonStr += "{ \"id\":\"" + std::string(ifname) + "\",\"rcv\":" + std::to_string(if2m->ifm_data.ifi_ibytes) + ",\"snd\":" + std::to_string(if2m->ifm_data.ifi_obytes) + " }"; + nRecords++; } } } diff --git a/src/Lib.Platform.MacOS/Platform.cs b/src/Lib.Platform.MacOS/Platform.cs index e575e735..ae65c8f4 100644 --- a/src/Lib.Platform.MacOS/Platform.cs +++ b/src/Lib.Platform.MacOS/Platform.cs @@ -919,14 +919,14 @@ public override Json GetRealtimeNetworkStats() { // Mono NetworkInterface::GetIPv4Statistics().BytesReceived always return 0 under OSX. - Json result = new Json(); - result.EnsureArray(); - int maxLen = 1024; byte[] buf = new byte[maxLen]; NativeMethods.GetRealtimeNetworkStats(buf, maxLen); string jNativeStr = System.Text.Encoding.ASCII.GetString(buf); + return Json.Parse(jNativeStr); + + /* TOCLEAN Json jNative = Json.Parse(jNativeStr); // Expect the sequence is the same. @@ -944,6 +944,7 @@ public override Json GetRealtimeNetworkStats() Int64 snd = jNativeIf["snd"].ValueInt64; Json jInterface = new Json(); jInterface["id"].Value = interfaces[i].Id; + jInterface["pazzoid"].Value = jNativeIf["idn"].ValueString; jInterface["rcv"].Value = rcv; jInterface["snd"].Value = snd; result.Append(jInterface); @@ -951,7 +952,11 @@ public override Json GetRealtimeNetworkStats() } } + System.IO.File.WriteAllText("/tmp/pazzo2.json", result.ToJsonPretty()); + // pazzo + return result; + */ } public override void OnNetworkInterfaceInfoBuild(NetworkInterface networkInterface, Json jNetworkInterface)