Skip to content

Commit

Permalink
v2.11.7
Browse files Browse the repository at this point in the history
  • Loading branch information
bernerdad committed Aug 19, 2024
1 parent ab0625c commit 1edfb29
Show file tree
Hide file tree
Showing 46 changed files with 863 additions and 343 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ The repository contains Dockerfile to simplify building process. Skip all the ot
```
- Install vcpkg:
```bash
sudo docker run --rm -v .:/w ws-builder /bin/bash -c "git clone https://github.com/Microsoft/vcpkg.git && git checkout 576379156e82da642f8d1834220876759f13534d && ./vcpkg/bootstrap-vcpkg.sh --disableMetrics"
sudo docker run --rm -v .:/w ws-builder /bin/bash -c "git clone https://github.com/Microsoft/vcpkg.git && cd vcpkg && git checkout 576379156e82da642f8d1834220876759f13534d && ./bootstrap-vcpkg.sh --disableMetrics"
```
- Build all the dependencies:
```bash
Expand Down
7 changes: 7 additions & 0 deletions backend/windows/windscribe_service/ipc/serialize_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,12 @@ void serialize(Archive & ar, CMD_CREATE_OPENVPN_ADAPTER & g, const unsigned int
ar & g.useDCODriver;
}

template<class Archive>
void serialize(Archive & ar, CMD_SSID_FROM_INTERFACE_GUID & g, const unsigned int version)
{
UNREFERENCED_PARAMETER(version);
ar & g.interfaceGUID;
}

} // namespace serialization
} // namespace boost
6 changes: 6 additions & 0 deletions backend/windows/windscribe_service/ipc/servicecommunication.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#define AA_COMMAND_DISABLE_DOH_SETTINGS 53
#define AA_COMMAND_ENABLE_DOH_SETTINGS 54
#define AA_COMMAND_CONFIGURE_WIREGUARD 55
#define AA_COMMAND_SSID_FROM_INTERFACE_GUID 56

#include <string>
#include <vector>
Expand Down Expand Up @@ -242,6 +243,11 @@ struct CMD_CREATE_OPENVPN_ADAPTER
bool useDCODriver;
};

struct CMD_SSID_FROM_INTERFACE_GUID
{
std::wstring interfaceGUID;
};

struct MessagePacketResult
{
__int64 id;
Expand Down
19 changes: 18 additions & 1 deletion backend/windows/windscribe_service/process_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,6 @@ MessagePacketResult disableDohSettings(boost::archive::text_iarchive &ia)
return mpr;
}


MessagePacketResult enableDohSettings(boost::archive::text_iarchive &ia)
{
MessagePacketResult mpr;
Expand Down Expand Up @@ -874,3 +873,21 @@ MessagePacketResult enableDohSettings(boost::archive::text_iarchive &ia)
Logger::instance().out(L"AA_COMMAND_ENABLE_DOH_SETTINGS");
return mpr;
}

MessagePacketResult ssidFromInterfaceGUID(boost::archive::text_iarchive &ia)
{
CMD_SSID_FROM_INTERFACE_GUID cmd;
ia >> cmd;

MessagePacketResult mpr;
try {
mpr.additionalString = Utils::ssidFromInterfaceGUID(cmd.interfaceGUID);
mpr.success = true;
}
catch (std::system_error &ex) {
mpr.exitCode = ex.code().value();
Logger::instance().out("ssidFromInterfaceGUID - %s", ex.what());
}

return mpr;
}
4 changes: 3 additions & 1 deletion backend/windows/windscribe_service/process_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ MessagePacketResult createOpenVPNAdapter(boost::archive::text_iarchive &ia);
MessagePacketResult removeOpenVPNAdapter(boost::archive::text_iarchive &ia);
MessagePacketResult disableDohSettings(boost::archive::text_iarchive &ia);
MessagePacketResult enableDohSettings(boost::archive::text_iarchive &ia);
MessagePacketResult ssidFromInterfaceGUID(boost::archive::text_iarchive &ia);

static const std::map<const int, std::function<MessagePacketResult(boost::archive::text_iarchive &)>> kCommands = {
{ AA_COMMAND_FIREWALL_ON, firewallOn },
Expand Down Expand Up @@ -135,7 +136,8 @@ static const std::map<const int, std::function<MessagePacketResult(boost::archiv
{ AA_COMMAND_CREATE_OPENVPN_ADAPTER, createOpenVPNAdapter },
{ AA_COMMAND_REMOVE_OPENVPN_ADAPTER, removeOpenVPNAdapter },
{ AA_COMMAND_DISABLE_DOH_SETTINGS, disableDohSettings },
{ AA_COMMAND_ENABLE_DOH_SETTINGS, enableDohSettings }
{ AA_COMMAND_ENABLE_DOH_SETTINGS, enableDohSettings },
{ AA_COMMAND_SSID_FROM_INTERFACE_GUID, ssidFromInterfaceGUID }
};

MessagePacketResult processCommand(int cmdId, const std::string &packet);
83 changes: 83 additions & 0 deletions backend/windows/windscribe_service/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
#include <shlobj.h>
#include <versionhelpers.h>
#include <WbemIdl.h>
#include <wlanapi.h>

#include <cwctype>

#include "logger.h"
#include "utils/executable_signature/executable_signature.h"
#include "utils/win32handle.h"
#include "utils/wsscopeguard.h"

#pragma comment(lib, "wbemuuid.lib")

Expand Down Expand Up @@ -567,4 +569,85 @@ bool isMacAddress(const std::wstring &value)
return valid;
}

std::string ssidFromInterfaceGUID(const std::wstring &interfaceGUID)
{
// This DLL is not available on default installs of Windows Server. Dynamically load it so
// the app doesn't fail to launch with a "DLL not found" error. App profiling was performed
// and indicated no performance degradation when dynamically loading and unloading the DLL.
const std::wstring dll = getSystemDir() + L"\\wlanapi.dll";
auto wlanDll = ::LoadLibraryEx(dll.c_str(), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (wlanDll == NULL) {
throw std::system_error(::GetLastError(), std::generic_category(), "wlanapi.dll could not be loaded");
}

auto freeDLL = wsl::wsScopeGuard([&] {
::FreeLibrary(wlanDll);
});

typedef DWORD (WINAPI * WlanOpenHandleFunc)(DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, PHANDLE phClientHandle);
typedef DWORD (WINAPI * WlanCloseHandleFunc)(HANDLE hClientHandle, PVOID pReserved);
typedef VOID (WINAPI * WlanFreeMemoryFunc)(PVOID pMemory);
typedef DWORD (WINAPI * WlanQueryInterfaceFunc)(HANDLE hClientHandle, CONST GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, PVOID pReserved,
PDWORD pdwDataSize, PVOID *ppData, PWLAN_OPCODE_VALUE_TYPE pWlanOpcodeValueType);

WlanOpenHandleFunc pfnWlanOpenHandle = (WlanOpenHandleFunc)::GetProcAddress(wlanDll, "WlanOpenHandle");
if (pfnWlanOpenHandle == NULL) {
throw std::system_error(::GetLastError(), std::generic_category(), "Failed to load WlanOpenHandle");
}

WlanCloseHandleFunc pfnWlanCloseHandle = (WlanCloseHandleFunc)::GetProcAddress(wlanDll, "WlanCloseHandle");
if (pfnWlanCloseHandle == NULL) {
throw std::system_error(::GetLastError(), std::generic_category(), "Failed to load WlanCloseHandle");
}

WlanFreeMemoryFunc pfnWlanFreeMemory = (WlanFreeMemoryFunc)::GetProcAddress(wlanDll, "WlanFreeMemory");
if (pfnWlanFreeMemory == NULL) {
throw std::system_error(::GetLastError(), std::generic_category(), "Failed to load WlanFreeMemory");
}

WlanQueryInterfaceFunc pfnWlanQueryInterface = (WlanQueryInterfaceFunc)::GetProcAddress(wlanDll, "WlanQueryInterface");
if (pfnWlanQueryInterface == NULL) {
throw std::system_error(::GetLastError(), std::generic_category(), "Failed to load WlanQueryInterface");
}

DWORD dwCurVersion = 0;
HANDLE hClient = NULL;
auto result = pfnWlanOpenHandle(2, NULL, &dwCurVersion, &hClient);
if (result != ERROR_SUCCESS) {
throw std::system_error(::GetLastError(), std::generic_category(), "WlanOpenHandle failed");
}

PWLAN_CONNECTION_ATTRIBUTES pConnectInfo = NULL;

auto freeWlanResources = wsl::wsScopeGuard([&] {
if (pConnectInfo != NULL) {
pfnWlanFreeMemory(pConnectInfo);
}

pfnWlanCloseHandle(hClient, NULL);
});

GUID actualGUID = guidFromString(interfaceGUID);

DWORD connectInfoSize = sizeof(WLAN_CONNECTION_ATTRIBUTES);
WLAN_OPCODE_VALUE_TYPE opCode = wlan_opcode_value_type_invalid;

result = pfnWlanQueryInterface(hClient, &actualGUID, wlan_intf_opcode_current_connection, NULL,
&connectInfoSize, (PVOID *) &pConnectInfo, &opCode);
if (result != ERROR_SUCCESS) {
throw std::system_error(::GetLastError(), std::generic_category(), "WlanQueryInterface failed");
}

std::string ssid;
const auto &dot11Ssid = pConnectInfo->wlanAssociationAttributes.dot11Ssid;
if (dot11Ssid.uSSIDLength > 0) {
ssid.reserve(dot11Ssid.uSSIDLength);
for (ULONG k = 0; k < dot11Ssid.uSSIDLength; k++) {
ssid.push_back(static_cast<char>(dot11Ssid.ucSSID[k]));
}
}

return ssid;
}

}
2 changes: 2 additions & 0 deletions backend/windows/windscribe_service/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ namespace Utils
bool addFilterV6(HANDLE engineHandle, std::vector<UINT64> *filterId, FWP_ACTION_TYPE type, UINT8 weight,
GUID subLayerKey, wchar_t *subLayerName, PNET_LUID pluid = nullptr,
const std::vector<Ip6AddressAndPrefix> *range = nullptr, bool persistent = true);

std::string ssidFromInterfaceGUID(const std::wstring &interfaceGUID);
};
7 changes: 0 additions & 7 deletions backend/windows/wireguard_service/ServiceMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <tlhelp32.h>

#include <chrono>
#include <codecvt>
#include <filesystem>
#include <fstream>
#include <iomanip>
Expand Down Expand Up @@ -278,12 +277,6 @@ int wmain(int argc, wchar_t *argv[])
// hMonitorThread.wait(5000);
//}

// Delete the config file.
dwAttrib = ::GetFileAttributes(configFile.c_str());
if (dwAttrib != INVALID_FILE_ATTRIBUTES) {
::DeleteFile(configFile.c_str());
}

debugOut("Windscribe WireGuard service stopped");

::FreeLibrary(hTunnelDLL);
Expand Down
28 changes: 15 additions & 13 deletions client/base/backend/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,23 +712,25 @@ void Backend::abortInitialization()
void Backend::handleNetworkChange(types::NetworkInterface networkInterface, bool manual)
{
bool newNetwork = true;

// find or assign friendly name before checking is network is the same as current network
QString friendlyName = networkInterface.networkOrSsid;

QVector<types::NetworkInterface> networkListOld = PersistentState::instance().networkWhitelist();
for (int i = 0; i < networkListOld.size(); i++) {
if (networkListOld[i].networkOrSsid== networkInterface.networkOrSsid) {
friendlyName = networkListOld[i].friendlyName;
newNetwork = false;
break;
}
}

if (friendlyName == "") {
QString friendlyName;
if (!networkInterface.networkOrSsid.isEmpty()) {
// find or assign friendly name before checking is network is the same as current network
friendlyName = networkInterface.networkOrSsid;
for (int i = 0; i < networkListOld.size(); i++) {
if (networkListOld[i].networkOrSsid== networkInterface.networkOrSsid) {
friendlyName = networkListOld[i].friendlyName;
newNetwork = false;
break;
}
}

if (friendlyName == "") {
friendlyName = networkInterface.networkOrSsid;
}
networkInterface.friendlyName = friendlyName;
}
networkInterface.friendlyName = friendlyName;

if (networkInterface.networkOrSsid != "") { // not a disconnect
// Add a new network as secured
Expand Down
6 changes: 6 additions & 0 deletions client/base/backend/preferences/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ const types::ConnectionSettings Preferences::networkPreferredProtocol(QString ne
return engineSettings_.networkPreferredProtocols()[networkOrSsid];
}

const QMap<QString, types::ConnectionSettings> Preferences::networkPreferredProtocols() const
{
return engineSettings_.networkPreferredProtocols();
}

bool Preferences::hasNetworkPreferredProtocol(QString networkOrSsid) const
{
return engineSettings_.networkPreferredProtocols().contains(networkOrSsid) &&
Expand All @@ -273,6 +278,7 @@ void Preferences::setNetworkPreferredProtocols(const QMap<QString, types::Connec
}
}


void Preferences::setNetworkPreferredProtocol(QString networkOrSsid, const types::ConnectionSettings &settings)
{
QMap<QString, types::ConnectionSettings> map = engineSettings_.networkPreferredProtocols();
Expand Down
1 change: 1 addition & 0 deletions client/base/backend/preferences/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Preferences : public QObject
void setNetworkWhiteList(const QVector<types::NetworkInterface> &l);

const types::ConnectionSettings networkPreferredProtocol(QString networkOrSsid) const;
const QMap<QString, types::ConnectionSettings> networkPreferredProtocols() const;
bool hasNetworkPreferredProtocol(QString networkOrSsid) const;
void setNetworkPreferredProtocol(QString networkOrSsid, const types::ConnectionSettings &preferredProtocol);
void setNetworkPreferredProtocols(const QMap<QString, types::ConnectionSettings> &preferredProtocols);
Expand Down
14 changes: 14 additions & 0 deletions client/common/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
2.11.7 (19/08/2024)
All:
* Improved more JSON validation cases. #1048
* Fixed the client logout after reboot. #1092
* Fixed wsnet does not compile from public repo. #1102
Windows:
* Improved logic to retry service start if the WireGuard service reports network configuration errors during start. #682
* Improved UX when an error occurs while enabling secure hotspot. #1005
* Fixed unable to query SSID on Windows 11 24H2. #1086
* Fixed connection issues on cellular modem. #1096
MacOS:
* Fixed potential app hang when retrieving OS DNS servers. #1089


2.11.6 (09/08/2024)
All:
* Fixed potential for uncaught exceptions thrown by the std::filesystem API to cause the app to crash. #1072
Expand Down
6 changes: 3 additions & 3 deletions client/common/types/enginesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,14 @@ void EngineSettingsData::fromJson(const QJsonObject &json)
}

if (json.contains(kJsonNetworkPreferredProtocolsProp) && json[kJsonNetworkPreferredProtocolsProp].isObject()) {
QMap<QString, types::ConnectionSettings> networkPreferredProtocols;
QMap<QString, types::ConnectionSettings> npp;
const QJsonObject protocolsObj = json[kJsonNetworkPreferredProtocolsProp].toObject();
for (const QString& networkBase64 : protocolsObj.keys()) {
if (protocolsObj[networkBase64].isObject()) {
networkPreferredProtocols.insert(Utils::fromBase64(networkBase64), types::ConnectionSettings(protocolsObj[networkBase64].toObject()));
npp.insert(Utils::fromBase64(networkBase64), types::ConnectionSettings(protocolsObj[networkBase64].toObject()));
}
}
networkPreferredProtocols = networkPreferredProtocols;
networkPreferredProtocols = npp;
}

if (json.contains(kJsonNetworkLastKnownGoodProtocolsProp) && json[kJsonNetworkLastKnownGoodProtocolsProp].isObject()) {
Expand Down
3 changes: 2 additions & 1 deletion client/common/types/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ enum NETWORK_INTERFACE_TYPE {
NETWORK_INTERFACE_NONE = 0,
NETWORK_INTERFACE_ETH = 1,
NETWORK_INTERFACE_WIFI = 2,
NETWORK_INTERFACE_PPP = 3
NETWORK_INTERFACE_PPP = 3,
NETWORK_INTERFACE_MOBILE_BROADBAND = 4
};

enum NETWORK_TRUST_TYPE {
Expand Down
4 changes: 2 additions & 2 deletions client/common/types/proxysettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const int typeIdProxySettings = qRegisterMetaType<types::ProxySettings>("types::

namespace types {

ProxySettings::ProxySettings(): option_(PROXY_OPTION_NONE), port_(0)
ProxySettings::ProxySettings() : option_(PROXY_OPTION_NONE), port_(0)
{
}

Expand All @@ -21,7 +21,7 @@ ProxySettings::ProxySettings(PROXY_OPTION option, const QString &address, uint p
username_ = username;
}

ProxySettings::ProxySettings(const QJsonObject &json)
ProxySettings::ProxySettings(const QJsonObject &json) : option_(PROXY_OPTION_NONE), port_(0)
{
if (json.contains(kJsonOptionProp) && json[kJsonOptionProp].isDouble()) {
option_ = PROXY_OPTION_fromInt(json[kJsonOptionProp].toInt());
Expand Down
2 changes: 2 additions & 0 deletions client/common/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ if (WIN32)
executable_signature/executable_signature_win.cpp
network_utils/network_utils_win.cpp
network_utils/network_utils_win.h
network_utils/wlan_utils_win.cpp
network_utils/wlan_utils_win.h
servicecontrolmanager.cpp
timer_win.cpp
timer_win.h
Expand Down
5 changes: 3 additions & 2 deletions client/common/utils/ipvalidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ bool IpValidation::isIp(const QString &str)

bool IpValidation::isIpCidr(const QString &str)
{
QRegExp ipCidrRegex("^([0-9]{1,3}\\.){3}[0-9]{1,3}(\\/([0-9]|[1-2][0-9]|3[0-2]))?$");
return ipCidrRegex.exactMatch(str);
const QString kIPRange("(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])");
const QRegExp kRegExp("^" + kIPRange + "\\." + kIPRange + "\\." + kIPRange + "\\." + kIPRange + "(\\/([0-9]|[1-2][0-9]|3[0-2]))?$");
return kRegExp.exactMatch(str);
}

bool IpValidation::isDomain(const QString &str)
Expand Down
1 change: 1 addition & 0 deletions client/common/utils/macutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace MacUtils
void setArrowCursor();

bool isLockdownMode();
QSet<QString> getOsDnsServers();

// CLI
bool isAppAlreadyRunning();
Expand Down
Loading

0 comments on commit 1edfb29

Please sign in to comment.