Skip to content

Commit 87fa428

Browse files
committed
v2.19.3
1 parent 0d6f012 commit 87fa428

Some content is hidden

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

55 files changed

+305
-190
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ See `build_all --help` for other build options.
137137
pyenv install 3.11.6
138138
pyenv global 3.11.6
139139
```
140-
- Install dmgbuild:
140+
- Install create-dmg:
141141
```bash
142-
python3 -m pip install dmgbuild
142+
brew install create-dmg
143143
```
144144

145145
- Install CMake v3.28.x or newer from [here](https://cmake.org/download/) and make sure that the cmake executable is in the path and available for execution. The project will build with older versions of CMake, but you may encounter some warnings.

libs/wsnet/include/wsnet/WSNetServerAPI.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class WSNetServerAPI : public scapix_object<WSNetServerAPI>
2121
public:
2222
virtual ~WSNetServerAPI() {}
2323

24-
// Set parameters allowing overriding domains (for example, api-php8.windscribe.com, assets-php8.windscribe.com, checkip-php8.windscribe.com)
24+
// Set parameters allowing overriding domains (for example, api-php8.windscribe.com, assets-php8.windscribe.com)
2525
// If the corresponding parameter is empty, the override is not used for the corresponding query type
2626
// The default behavior - all values are empty
27-
virtual void setApiResolutionsSettings(const std::string &apiRoot, const std::string &assetsRoot, const std::string &checkIpRoot) = 0;
27+
virtual void setApiResolutionsSettings(const std::string &apiRoot, const std::string &assetsRoot) = 0;
2828

2929
virtual void setIgnoreSslErrors(bool bIgnore) = 0;
3030

@@ -77,6 +77,9 @@ class WSNetServerAPI : public scapix_object<WSNetServerAPI>
7777

7878
virtual std::shared_ptr<WSNetCancelableCallback> staticIps(const std::string &authHash, std::uint32_t version, WSNetRequestFinishedCallback callback) = 0;
7979

80+
// use this API call for connectivity tests when a VPN is connected
81+
// this request is always made through the primary domain windscribe.com and also has a backup domain in case the first one returns something unexpecte.
82+
// this request is intended for connectivity tests only and it does not use a failover mechanism.
8083
virtual std::shared_ptr<WSNetCancelableCallback> pingTest(std::uint32_t timeoutMs, WSNetRequestFinishedCallback callback) = 0;
8184

8285
// pcpid parameter is optional and can be empty string
@@ -97,6 +100,7 @@ class WSNetServerAPI : public scapix_object<WSNetServerAPI>
97100
virtual std::shared_ptr<WSNetCancelableCallback> wgConfigsPskRekey(const std::string &authHash, const std::string &clientPublicKey,
98101
WSNetRequestFinishedCallback callback) = 0;
99102

103+
// returns your IP address, uses a failover mechanism, so it can work in restricted networks when a VPN is disconnected unlike PingTest
100104
virtual std::shared_ptr<WSNetCancelableCallback> myIP(WSNetRequestFinishedCallback callback) = 0;
101105

102106
virtual std::shared_ptr<WSNetCancelableCallback> mobileBillingPlans(const std::string &authHash, const std::string &mobilePlanType, const std::string &promo, int version, WSNetRequestFinishedCallback callback) = 0;

libs/wsnet/src/api/baserequest.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ void BaseRequest::setApiOverrideSettings(const ApiOverrideSettings &apiOverrideS
2626
domainOverride_ = apiOverrideSettings.apiRoot;
2727
else if (subDomainType_ == SubdomainType::kAssets && !apiOverrideSettings.assetsRoot.empty())
2828
domainOverride_ = apiOverrideSettings.assetsRoot;
29-
else if (subDomainType_ == SubdomainType::kTunnelTest && !apiOverrideSettings.checkIpRoot.empty())
30-
domainOverride_ = apiOverrideSettings.checkIpRoot;
3129
}
3230

3331
bool BaseRequest::isApiDomainOverriden() const
@@ -114,8 +112,6 @@ std::string BaseRequest::hostname(const std::string &domain, SubdomainType subdo
114112
if (utils::isIpAddress(domain)) {
115113
if (subdomain == SubdomainType::kAssets) {
116114
return domain + "/" + Settings::instance().serverAssetsSubdomain();
117-
} else if (subdomain == SubdomainType::kTunnelTest) {
118-
return domain + "/" + Settings::instance().serverTunnelTestSubdomain();
119115
} else {
120116
return domain;
121117
}
@@ -124,8 +120,6 @@ std::string BaseRequest::hostname(const std::string &domain, SubdomainType subdo
124120
return Settings::instance().serverApiSubdomain() + "." + domain;
125121
else if (subdomain == SubdomainType::kAssets)
126122
return Settings::instance().serverAssetsSubdomain() + "." + domain;
127-
else if (subdomain == SubdomainType::kTunnelTest)
128-
return Settings::instance().serverTunnelTestSubdomain() + "." + domain;
129123
}
130124
}
131125
// if it is an overridden domain, return without transformations

libs/wsnet/src/api/baserequest.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace wsnet {
1010

11-
enum class SubdomainType { kApi, kAssets, kTunnelTest, kBridgeAPI };
11+
enum class SubdomainType { kApi, kAssets, kBridgeAPI };
1212
enum class RequestPriority { kNormal, kHigh };
1313

1414
using RequestFinishedCallback = std::shared_ptr<CancelableCallback<WSNetRequestFinishedCallback>>;
@@ -18,11 +18,10 @@ struct ApiOverrideSettings
1818
{
1919
std::string apiRoot;
2020
std::string assetsRoot;
21-
std::string checkIpRoot;
2221

2322
bool isOverriden() const
2423
{
25-
return !apiRoot.empty() || !assetsRoot.empty() || !checkIpRoot.empty();
24+
return !apiRoot.empty() || !assetsRoot.empty();
2625
}
2726
};
2827

libs/wsnet/src/api/serverapi/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
target_sources(wsnet PRIVATE
22
failedfailovers.h
3+
pingtest.cpp
4+
pingtest.h
35
requestexecuterviafailover.cpp
46
requestexecuterviafailover.h
57
serverapi.cpp
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include "pingtest.h"
2+
#include <skyr/url.hpp>
3+
#include "utils/urlquery_utils.h"
4+
#include "utils/utils.h"
5+
6+
namespace wsnet {
7+
8+
PingTest::PingTest(WSNetHttpNetworkManager *httpNetworkManager) : httpNetworkManager_(httpNetworkManager)
9+
{
10+
auto tunnelTestEndpoints = Settings::instance().tunnelTestEndpoints();
11+
for (const std::string &it : tunnelTestEndpoints) {
12+
auto url = skyr::url("https://" + it);
13+
auto &sp = url.search_parameters();
14+
urlquery_utils::addPlatformQueryItems(sp);
15+
endpoints_.push_back(url);
16+
}
17+
}
18+
19+
void PingTest::doPingTest(std::uint32_t timeoutMs, RequestFinishedCallback callback)
20+
{
21+
assert(!endpoints_.empty());
22+
assert(callback != nullptr);
23+
// Do the first ping test through the primary domain
24+
auto httpRequest = httpNetworkManager_->createGetRequest(endpoints_[0].c_str(), timeoutMs, false);
25+
// We do not use DNS cache, as we need to verify the functionality of the connected VPN's DNS.
26+
httpRequest->setUseDnsCache(false);
27+
httpRequest->setIsWhiteListIps(false);
28+
29+
using namespace std::placeholders;
30+
std::uint64_t requestId = curUniqueId_++;
31+
RequestInfo ri { callback, 0, timeoutMs};
32+
activeRequests_[requestId] = ri;
33+
httpNetworkManager_->executeRequestEx(httpRequest, requestId, std::bind(&PingTest::onHttpNetworkRequestFinished, this, _1, _2, _3, _4));
34+
}
35+
36+
void PingTest::onHttpNetworkRequestFinished(std::uint64_t requestId, std::uint32_t elapsedMs, std::shared_ptr<WSNetRequestError> error, const std::string &data)
37+
{
38+
auto it = activeRequests_.find(requestId);
39+
assert(it != activeRequests_.end());
40+
41+
if (it->second.callback->isCanceled()) {
42+
activeRequests_.erase(it);
43+
return;
44+
}
45+
46+
bool bSuccess = false;
47+
if (error->isSuccess()) {
48+
auto trimmedData = utils::trim(data);
49+
if (utils::isIpAddress(trimmedData)) {
50+
it->second.callback->call(ApiRetCode::kSuccess, trimmedData);
51+
bSuccess = true;
52+
} else if (it->second.curEndpointInd < (endpoints_.size() - 1)) {
53+
// try next backup endpoint
54+
it->second.curEndpointInd++;
55+
auto httpRequest = httpNetworkManager_->createGetRequest(endpoints_[it->second.curEndpointInd].c_str(), it->second.timeoutMs, false);
56+
httpRequest->setUseDnsCache(false);
57+
httpRequest->setIsWhiteListIps(false);
58+
using namespace std::placeholders;
59+
httpNetworkManager_->executeRequestEx(httpRequest, requestId, std::bind(&PingTest::onHttpNetworkRequestFinished, this, _1, _2, _3, _4));
60+
return;
61+
}
62+
}
63+
if (!bSuccess) {
64+
it->second.callback->call(ApiRetCode::kNetworkError, "");
65+
}
66+
activeRequests_.erase(it);
67+
}
68+
69+
70+
} // namespace wsnet
71+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#pragma once
2+
3+
#include <skyr/url.hpp>
4+
#include "WSNetHttpNetworkManager.h"
5+
#include "../baserequest.h"
6+
7+
namespace wsnet {
8+
9+
// This request is different from all the others, so it's placed in a separate class.
10+
// This request is always made through the primary domain windscribe.com and also has a backup domain in case the first one returns something unexpected.
11+
// This request is intended for connectivity tests only and it does not use a failover mechanism.
12+
class PingTest
13+
{
14+
public:
15+
explicit PingTest(WSNetHttpNetworkManager *httpNetworkManager);
16+
virtual ~PingTest() {};
17+
18+
void doPingTest(std::uint32_t timeoutMs, RequestFinishedCallback callback);
19+
20+
21+
private:
22+
WSNetHttpNetworkManager *httpNetworkManager_;
23+
std::uint64_t curUniqueId_ = 0;
24+
std::vector<skyr::url> endpoints_;
25+
26+
struct RequestInfo {
27+
RequestFinishedCallback callback;
28+
int curEndpointInd;
29+
std::uint32_t timeoutMs;
30+
};
31+
std::map<std::uint64_t, RequestInfo> activeRequests_;
32+
33+
void onHttpNetworkRequestFinished(std::uint64_t requestId, std::uint32_t elapsedMs, std::shared_ptr<WSNetRequestError> error, const std::string &data);
34+
};
35+
36+
} // namespace wsnet
37+

libs/wsnet/src/api/serverapi/serverapi.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ ServerAPI::ServerAPI(boost::asio::io_context &io_context, WSNetHttpNetworkManage
1111
io_context_(io_context),
1212
persistentSettings_(persistentSettings),
1313
advancedParameters_(advancedParameters),
14-
connectState_(connectState)
14+
connectState_(connectState),
15+
pingTest_(httpNetworkManager)
1516
{
1617
impl_ = std::make_unique<ServerAPI_impl>(httpNetworkManager, failoverContainer, persistentSettings_, advancedParameters, connectState);
1718
subscriberId_ = connectState_.subscribeConnectedToVpnState(std::bind(&ServerAPI::onVPNConnectStateChanged, this, std::placeholders::_1));
@@ -22,10 +23,10 @@ ServerAPI::~ServerAPI()
2223
connectState_.unsubscribeConnectedToVpnState(subscriberId_);
2324
}
2425

25-
void ServerAPI::setApiResolutionsSettings(const std::string &apiRoot, const std::string &assetsRoot, const std::string &checkIpRoot)
26+
void ServerAPI::setApiResolutionsSettings(const std::string &apiRoot, const std::string &assetsRoot)
2627
{
27-
boost::asio::post(io_context_, [this, apiRoot, assetsRoot, checkIpRoot] {
28-
impl_->setApiResolutionsSettings(apiRoot, assetsRoot, checkIpRoot);
28+
boost::asio::post(io_context_, [this, apiRoot, assetsRoot] {
29+
impl_->setApiResolutionsSettings(apiRoot, assetsRoot);
2930
});
3031
}
3132

@@ -197,9 +198,9 @@ std::shared_ptr<WSNetCancelableCallback> ServerAPI::staticIps(const std::string
197198

198199
std::shared_ptr<WSNetCancelableCallback> ServerAPI::pingTest(std::uint32_t timeoutMs, WSNetRequestFinishedCallback callback)
199200
{
201+
// PingTest does not use a failover mechanism and has backup endpoint attempts, so it is implemented in a separate class
200202
auto cancelableCallback = std::make_shared<CancelableCallback<WSNetRequestFinishedCallback>>(callback);
201-
BaseRequest *request = serverapi_requests_factory::pingTest(timeoutMs, cancelableCallback);
202-
boost::asio::post(io_context_, [this, request] { impl_->executeRequest(std::unique_ptr<BaseRequest>(request)); });
203+
boost::asio::post(io_context_, [this, timeoutMs, cancelableCallback] { pingTest_.doPingTest(timeoutMs, cancelableCallback); });
203204
return cancelableCallback;
204205
}
205206

libs/wsnet/src/api/serverapi/serverapi.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "failover/ifailovercontainer.h"
88
#include "utils/persistentsettings.h"
99
#include "connectstate.h"
10+
#include "pingtest.h"
1011

1112
namespace wsnet {
1213

@@ -19,7 +20,7 @@ class ServerAPI : public WSNetServerAPI
1920
PersistentSettings &persistentSettings, WSNetAdvancedParameters *advancedParameters, ConnectState &connectState);
2021
virtual ~ServerAPI();
2122

22-
void setApiResolutionsSettings(const std::string &apiRoot, const std::string &assetsRoot, const std::string &checkIpRoot) override;
23+
void setApiResolutionsSettings(const std::string &apiRoot, const std::string &assetsRoot) override;
2324
void setIgnoreSslErrors(bool bIgnore) override;
2425
void resetFailover() override;
2526

@@ -121,6 +122,7 @@ class ServerAPI : public WSNetServerAPI
121122
WSNetAdvancedParameters *advancedParameters_;
122123
ConnectState &connectState_;
123124
std::uint32_t subscriberId_;
125+
PingTest pingTest_;
124126

125127
void onVPNConnectStateChanged(bool isConnected);
126128
};

libs/wsnet/src/api/serverapi/serverapi_impl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ ServerAPI_impl::~ServerAPI_impl()
3636
}
3737
}
3838

39-
void ServerAPI_impl::setApiResolutionsSettings(const std::string &apiRoot, const std::string &assetsRoot, const std::string &checkIpRoot)
39+
void ServerAPI_impl::setApiResolutionsSettings(const std::string &apiRoot, const std::string &assetsRoot)
4040
{
4141
apiOverrideSettings_.apiRoot = apiRoot;
4242
apiOverrideSettings_.assetsRoot = assetsRoot;
43-
apiOverrideSettings_.checkIpRoot = checkIpRoot;
4443
if (!apiOverrideSettings_.isOverriden()) {
4544
g_logger->info("ServerAPI_impl::setApiResolutionsSettings, default behavior, no overridden domains");
4645
} else {
47-
g_logger->info("ServerAPI_impl::setApiResolutionsSettings, overridden domains are set, apiRoot = {}, assetsRoot = {}, checkIpRoot = {}", apiRoot, assetsRoot, checkIpRoot);
46+
g_logger->info("ServerAPI_impl::setApiResolutionsSettings, overridden domains are set, apiRoot = {}, assetsRoot = {}", apiRoot, assetsRoot);
4847
}
4948
}
5049

0 commit comments

Comments
 (0)