Skip to content

Commit 1edfb29

Browse files
committed
v2.11.7
1 parent ab0625c commit 1edfb29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+863
-343
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ The repository contains Dockerfile to simplify building process. Skip all the ot
164164
```
165165
- Install vcpkg:
166166
```bash
167-
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"
167+
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"
168168
```
169169
- Build all the dependencies:
170170
```bash

backend/windows/windscribe_service/ipc/serialize_structs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,12 @@ void serialize(Archive & ar, CMD_CREATE_OPENVPN_ADAPTER & g, const unsigned int
212212
ar & g.useDCODriver;
213213
}
214214

215+
template<class Archive>
216+
void serialize(Archive & ar, CMD_SSID_FROM_INTERFACE_GUID & g, const unsigned int version)
217+
{
218+
UNREFERENCED_PARAMETER(version);
219+
ar & g.interfaceGUID;
220+
}
221+
215222
} // namespace serialization
216223
} // namespace boost

backend/windows/windscribe_service/ipc/servicecommunication.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#define AA_COMMAND_DISABLE_DOH_SETTINGS 53
5757
#define AA_COMMAND_ENABLE_DOH_SETTINGS 54
5858
#define AA_COMMAND_CONFIGURE_WIREGUARD 55
59+
#define AA_COMMAND_SSID_FROM_INTERFACE_GUID 56
5960

6061
#include <string>
6162
#include <vector>
@@ -242,6 +243,11 @@ struct CMD_CREATE_OPENVPN_ADAPTER
242243
bool useDCODriver;
243244
};
244245

246+
struct CMD_SSID_FROM_INTERFACE_GUID
247+
{
248+
std::wstring interfaceGUID;
249+
};
250+
245251
struct MessagePacketResult
246252
{
247253
__int64 id;

backend/windows/windscribe_service/process_command.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,6 @@ MessagePacketResult disableDohSettings(boost::archive::text_iarchive &ia)
838838
return mpr;
839839
}
840840

841-
842841
MessagePacketResult enableDohSettings(boost::archive::text_iarchive &ia)
843842
{
844843
MessagePacketResult mpr;
@@ -874,3 +873,21 @@ MessagePacketResult enableDohSettings(boost::archive::text_iarchive &ia)
874873
Logger::instance().out(L"AA_COMMAND_ENABLE_DOH_SETTINGS");
875874
return mpr;
876875
}
876+
877+
MessagePacketResult ssidFromInterfaceGUID(boost::archive::text_iarchive &ia)
878+
{
879+
CMD_SSID_FROM_INTERFACE_GUID cmd;
880+
ia >> cmd;
881+
882+
MessagePacketResult mpr;
883+
try {
884+
mpr.additionalString = Utils::ssidFromInterfaceGUID(cmd.interfaceGUID);
885+
mpr.success = true;
886+
}
887+
catch (std::system_error &ex) {
888+
mpr.exitCode = ex.code().value();
889+
Logger::instance().out("ssidFromInterfaceGUID - %s", ex.what());
890+
}
891+
892+
return mpr;
893+
}

backend/windows/windscribe_service/process_command.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ MessagePacketResult createOpenVPNAdapter(boost::archive::text_iarchive &ia);
8181
MessagePacketResult removeOpenVPNAdapter(boost::archive::text_iarchive &ia);
8282
MessagePacketResult disableDohSettings(boost::archive::text_iarchive &ia);
8383
MessagePacketResult enableDohSettings(boost::archive::text_iarchive &ia);
84+
MessagePacketResult ssidFromInterfaceGUID(boost::archive::text_iarchive &ia);
8485

8586
static const std::map<const int, std::function<MessagePacketResult(boost::archive::text_iarchive &)>> kCommands = {
8687
{ AA_COMMAND_FIREWALL_ON, firewallOn },
@@ -135,7 +136,8 @@ static const std::map<const int, std::function<MessagePacketResult(boost::archiv
135136
{ AA_COMMAND_CREATE_OPENVPN_ADAPTER, createOpenVPNAdapter },
136137
{ AA_COMMAND_REMOVE_OPENVPN_ADAPTER, removeOpenVPNAdapter },
137138
{ AA_COMMAND_DISABLE_DOH_SETTINGS, disableDohSettings },
138-
{ AA_COMMAND_ENABLE_DOH_SETTINGS, enableDohSettings }
139+
{ AA_COMMAND_ENABLE_DOH_SETTINGS, enableDohSettings },
140+
{ AA_COMMAND_SSID_FROM_INTERFACE_GUID, ssidFromInterfaceGUID }
139141
};
140142

141143
MessagePacketResult processCommand(int cmdId, const std::string &packet);

backend/windows/windscribe_service/utils.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
#include <shlobj.h>
99
#include <versionhelpers.h>
1010
#include <WbemIdl.h>
11+
#include <wlanapi.h>
1112

1213
#include <cwctype>
1314

1415
#include "logger.h"
1516
#include "utils/executable_signature/executable_signature.h"
1617
#include "utils/win32handle.h"
18+
#include "utils/wsscopeguard.h"
1719

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

@@ -567,4 +569,85 @@ bool isMacAddress(const std::wstring &value)
567569
return valid;
568570
}
569571

572+
std::string ssidFromInterfaceGUID(const std::wstring &interfaceGUID)
573+
{
574+
// This DLL is not available on default installs of Windows Server. Dynamically load it so
575+
// the app doesn't fail to launch with a "DLL not found" error. App profiling was performed
576+
// and indicated no performance degradation when dynamically loading and unloading the DLL.
577+
const std::wstring dll = getSystemDir() + L"\\wlanapi.dll";
578+
auto wlanDll = ::LoadLibraryEx(dll.c_str(), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
579+
if (wlanDll == NULL) {
580+
throw std::system_error(::GetLastError(), std::generic_category(), "wlanapi.dll could not be loaded");
581+
}
582+
583+
auto freeDLL = wsl::wsScopeGuard([&] {
584+
::FreeLibrary(wlanDll);
585+
});
586+
587+
typedef DWORD (WINAPI * WlanOpenHandleFunc)(DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, PHANDLE phClientHandle);
588+
typedef DWORD (WINAPI * WlanCloseHandleFunc)(HANDLE hClientHandle, PVOID pReserved);
589+
typedef VOID (WINAPI * WlanFreeMemoryFunc)(PVOID pMemory);
590+
typedef DWORD (WINAPI * WlanQueryInterfaceFunc)(HANDLE hClientHandle, CONST GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, PVOID pReserved,
591+
PDWORD pdwDataSize, PVOID *ppData, PWLAN_OPCODE_VALUE_TYPE pWlanOpcodeValueType);
592+
593+
WlanOpenHandleFunc pfnWlanOpenHandle = (WlanOpenHandleFunc)::GetProcAddress(wlanDll, "WlanOpenHandle");
594+
if (pfnWlanOpenHandle == NULL) {
595+
throw std::system_error(::GetLastError(), std::generic_category(), "Failed to load WlanOpenHandle");
596+
}
597+
598+
WlanCloseHandleFunc pfnWlanCloseHandle = (WlanCloseHandleFunc)::GetProcAddress(wlanDll, "WlanCloseHandle");
599+
if (pfnWlanCloseHandle == NULL) {
600+
throw std::system_error(::GetLastError(), std::generic_category(), "Failed to load WlanCloseHandle");
601+
}
602+
603+
WlanFreeMemoryFunc pfnWlanFreeMemory = (WlanFreeMemoryFunc)::GetProcAddress(wlanDll, "WlanFreeMemory");
604+
if (pfnWlanFreeMemory == NULL) {
605+
throw std::system_error(::GetLastError(), std::generic_category(), "Failed to load WlanFreeMemory");
606+
}
607+
608+
WlanQueryInterfaceFunc pfnWlanQueryInterface = (WlanQueryInterfaceFunc)::GetProcAddress(wlanDll, "WlanQueryInterface");
609+
if (pfnWlanQueryInterface == NULL) {
610+
throw std::system_error(::GetLastError(), std::generic_category(), "Failed to load WlanQueryInterface");
611+
}
612+
613+
DWORD dwCurVersion = 0;
614+
HANDLE hClient = NULL;
615+
auto result = pfnWlanOpenHandle(2, NULL, &dwCurVersion, &hClient);
616+
if (result != ERROR_SUCCESS) {
617+
throw std::system_error(::GetLastError(), std::generic_category(), "WlanOpenHandle failed");
618+
}
619+
620+
PWLAN_CONNECTION_ATTRIBUTES pConnectInfo = NULL;
621+
622+
auto freeWlanResources = wsl::wsScopeGuard([&] {
623+
if (pConnectInfo != NULL) {
624+
pfnWlanFreeMemory(pConnectInfo);
625+
}
626+
627+
pfnWlanCloseHandle(hClient, NULL);
628+
});
629+
630+
GUID actualGUID = guidFromString(interfaceGUID);
631+
632+
DWORD connectInfoSize = sizeof(WLAN_CONNECTION_ATTRIBUTES);
633+
WLAN_OPCODE_VALUE_TYPE opCode = wlan_opcode_value_type_invalid;
634+
635+
result = pfnWlanQueryInterface(hClient, &actualGUID, wlan_intf_opcode_current_connection, NULL,
636+
&connectInfoSize, (PVOID *) &pConnectInfo, &opCode);
637+
if (result != ERROR_SUCCESS) {
638+
throw std::system_error(::GetLastError(), std::generic_category(), "WlanQueryInterface failed");
639+
}
640+
641+
std::string ssid;
642+
const auto &dot11Ssid = pConnectInfo->wlanAssociationAttributes.dot11Ssid;
643+
if (dot11Ssid.uSSIDLength > 0) {
644+
ssid.reserve(dot11Ssid.uSSIDLength);
645+
for (ULONG k = 0; k < dot11Ssid.uSSIDLength; k++) {
646+
ssid.push_back(static_cast<char>(dot11Ssid.ucSSID[k]));
647+
}
648+
}
649+
650+
return ssid;
651+
}
652+
570653
}

backend/windows/windscribe_service/utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ namespace Utils
4242
bool addFilterV6(HANDLE engineHandle, std::vector<UINT64> *filterId, FWP_ACTION_TYPE type, UINT8 weight,
4343
GUID subLayerKey, wchar_t *subLayerName, PNET_LUID pluid = nullptr,
4444
const std::vector<Ip6AddressAndPrefix> *range = nullptr, bool persistent = true);
45+
46+
std::string ssidFromInterfaceGUID(const std::wstring &interfaceGUID);
4547
};

backend/windows/wireguard_service/ServiceMain.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <tlhelp32.h>
44

55
#include <chrono>
6-
#include <codecvt>
76
#include <filesystem>
87
#include <fstream>
98
#include <iomanip>
@@ -278,12 +277,6 @@ int wmain(int argc, wchar_t *argv[])
278277
// hMonitorThread.wait(5000);
279278
//}
280279

281-
// Delete the config file.
282-
dwAttrib = ::GetFileAttributes(configFile.c_str());
283-
if (dwAttrib != INVALID_FILE_ATTRIBUTES) {
284-
::DeleteFile(configFile.c_str());
285-
}
286-
287280
debugOut("Windscribe WireGuard service stopped");
288281

289282
::FreeLibrary(hTunnelDLL);

client/base/backend/backend.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -712,23 +712,25 @@ void Backend::abortInitialization()
712712
void Backend::handleNetworkChange(types::NetworkInterface networkInterface, bool manual)
713713
{
714714
bool newNetwork = true;
715-
716-
// find or assign friendly name before checking is network is the same as current network
717-
QString friendlyName = networkInterface.networkOrSsid;
718-
719715
QVector<types::NetworkInterface> networkListOld = PersistentState::instance().networkWhitelist();
720-
for (int i = 0; i < networkListOld.size(); i++) {
721-
if (networkListOld[i].networkOrSsid== networkInterface.networkOrSsid) {
722-
friendlyName = networkListOld[i].friendlyName;
723-
newNetwork = false;
724-
break;
725-
}
726-
}
727716

728-
if (friendlyName == "") {
717+
QString friendlyName;
718+
if (!networkInterface.networkOrSsid.isEmpty()) {
719+
// find or assign friendly name before checking is network is the same as current network
729720
friendlyName = networkInterface.networkOrSsid;
721+
for (int i = 0; i < networkListOld.size(); i++) {
722+
if (networkListOld[i].networkOrSsid== networkInterface.networkOrSsid) {
723+
friendlyName = networkListOld[i].friendlyName;
724+
newNetwork = false;
725+
break;
726+
}
727+
}
728+
729+
if (friendlyName == "") {
730+
friendlyName = networkInterface.networkOrSsid;
731+
}
732+
networkInterface.friendlyName = friendlyName;
730733
}
731-
networkInterface.friendlyName = friendlyName;
732734

733735
if (networkInterface.networkOrSsid != "") { // not a disconnect
734736
// Add a new network as secured

client/base/backend/preferences/preferences.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ const types::ConnectionSettings Preferences::networkPreferredProtocol(QString ne
257257
return engineSettings_.networkPreferredProtocols()[networkOrSsid];
258258
}
259259

260+
const QMap<QString, types::ConnectionSettings> Preferences::networkPreferredProtocols() const
261+
{
262+
return engineSettings_.networkPreferredProtocols();
263+
}
264+
260265
bool Preferences::hasNetworkPreferredProtocol(QString networkOrSsid) const
261266
{
262267
return engineSettings_.networkPreferredProtocols().contains(networkOrSsid) &&
@@ -273,6 +278,7 @@ void Preferences::setNetworkPreferredProtocols(const QMap<QString, types::Connec
273278
}
274279
}
275280

281+
276282
void Preferences::setNetworkPreferredProtocol(QString networkOrSsid, const types::ConnectionSettings &settings)
277283
{
278284
QMap<QString, types::ConnectionSettings> map = engineSettings_.networkPreferredProtocols();

client/base/backend/preferences/preferences.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Preferences : public QObject
6161
void setNetworkWhiteList(const QVector<types::NetworkInterface> &l);
6262

6363
const types::ConnectionSettings networkPreferredProtocol(QString networkOrSsid) const;
64+
const QMap<QString, types::ConnectionSettings> networkPreferredProtocols() const;
6465
bool hasNetworkPreferredProtocol(QString networkOrSsid) const;
6566
void setNetworkPreferredProtocol(QString networkOrSsid, const types::ConnectionSettings &preferredProtocol);
6667
void setNetworkPreferredProtocols(const QMap<QString, types::ConnectionSettings> &preferredProtocols);

client/common/changelog.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2.11.7 (19/08/2024)
2+
All:
3+
* Improved more JSON validation cases. #1048
4+
* Fixed the client logout after reboot. #1092
5+
* Fixed wsnet does not compile from public repo. #1102
6+
Windows:
7+
* Improved logic to retry service start if the WireGuard service reports network configuration errors during start. #682
8+
* Improved UX when an error occurs while enabling secure hotspot. #1005
9+
* Fixed unable to query SSID on Windows 11 24H2. #1086
10+
* Fixed connection issues on cellular modem. #1096
11+
MacOS:
12+
* Fixed potential app hang when retrieving OS DNS servers. #1089
13+
14+
115
2.11.6 (09/08/2024)
216
All:
317
* Fixed potential for uncaught exceptions thrown by the std::filesystem API to cause the app to crash. #1072

client/common/types/enginesettings.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,14 +486,14 @@ void EngineSettingsData::fromJson(const QJsonObject &json)
486486
}
487487

488488
if (json.contains(kJsonNetworkPreferredProtocolsProp) && json[kJsonNetworkPreferredProtocolsProp].isObject()) {
489-
QMap<QString, types::ConnectionSettings> networkPreferredProtocols;
489+
QMap<QString, types::ConnectionSettings> npp;
490490
const QJsonObject protocolsObj = json[kJsonNetworkPreferredProtocolsProp].toObject();
491491
for (const QString& networkBase64 : protocolsObj.keys()) {
492492
if (protocolsObj[networkBase64].isObject()) {
493-
networkPreferredProtocols.insert(Utils::fromBase64(networkBase64), types::ConnectionSettings(protocolsObj[networkBase64].toObject()));
493+
npp.insert(Utils::fromBase64(networkBase64), types::ConnectionSettings(protocolsObj[networkBase64].toObject()));
494494
}
495495
}
496-
networkPreferredProtocols = networkPreferredProtocols;
496+
networkPreferredProtocols = npp;
497497
}
498498

499499
if (json.contains(kJsonNetworkLastKnownGoodProtocolsProp) && json[kJsonNetworkLastKnownGoodProtocolsProp].isObject()) {

client/common/types/enums.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ enum NETWORK_INTERFACE_TYPE {
117117
NETWORK_INTERFACE_NONE = 0,
118118
NETWORK_INTERFACE_ETH = 1,
119119
NETWORK_INTERFACE_WIFI = 2,
120-
NETWORK_INTERFACE_PPP = 3
120+
NETWORK_INTERFACE_PPP = 3,
121+
NETWORK_INTERFACE_MOBILE_BROADBAND = 4
121122
};
122123

123124
enum NETWORK_TRUST_TYPE {

client/common/types/proxysettings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const int typeIdProxySettings = qRegisterMetaType<types::ProxySettings>("types::
88

99
namespace types {
1010

11-
ProxySettings::ProxySettings(): option_(PROXY_OPTION_NONE), port_(0)
11+
ProxySettings::ProxySettings() : option_(PROXY_OPTION_NONE), port_(0)
1212
{
1313
}
1414

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

24-
ProxySettings::ProxySettings(const QJsonObject &json)
24+
ProxySettings::ProxySettings(const QJsonObject &json) : option_(PROXY_OPTION_NONE), port_(0)
2525
{
2626
if (json.contains(kJsonOptionProp) && json[kJsonOptionProp].isDouble()) {
2727
option_ = PROXY_OPTION_fromInt(json[kJsonOptionProp].toInt());

client/common/utils/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ if (WIN32)
3232
executable_signature/executable_signature_win.cpp
3333
network_utils/network_utils_win.cpp
3434
network_utils/network_utils_win.h
35+
network_utils/wlan_utils_win.cpp
36+
network_utils/wlan_utils_win.h
3537
servicecontrolmanager.cpp
3638
timer_win.cpp
3739
timer_win.h

client/common/utils/ipvalidation.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ bool IpValidation::isIp(const QString &str)
1616

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

2324
bool IpValidation::isDomain(const QString &str)

client/common/utils/macutils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace MacUtils
1919
void setArrowCursor();
2020

2121
bool isLockdownMode();
22+
QSet<QString> getOsDnsServers();
2223

2324
// CLI
2425
bool isAppAlreadyRunning();

0 commit comments

Comments
 (0)