Skip to content

Commit dda3af6

Browse files
committed
v2.11.6
1 parent bca1850 commit dda3af6

File tree

215 files changed

+3493
-1912
lines changed

Some content is hidden

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

215 files changed

+3493
-1912
lines changed

.gitlab-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,9 @@ build:artifact:links:
825825
- echo ${NEXUS_PATH_BRANCH_UPLOAD}/windows-arm64/Windscribe_${VERSION}_arm64.exe
826826
- echo ${NEXUS_PATH_BRANCH_UPLOAD}/macos/Windscribe_$VERSION.dmg
827827
- echo ${NEXUS_PATH_BRANCH_UPLOAD}/linux/windscribe_${VERSION}_amd64.deb
828+
- echo ${NEXUS_PATH_BRANCH_UPLOAD}/linux-arm64/windscribe_${VERSION}_arm64.deb
828829
- echo ${NEXUS_PATH_BRANCH_UPLOAD}/linux/windscribe-cli_${VERSION}_amd64.deb
830+
- echo ${NEXUS_PATH_BRANCH_UPLOAD}/linux-arm64/windscribe-cli_${VERSION}_arm64.deb
829831
- echo ${NEXUS_PATH_BRANCH_UPLOAD}/linux/windscribe_${VERSION}_x86_64_fedora.rpm
830832
- echo ${NEXUS_PATH_BRANCH_UPLOAD}/linux/windscribe-cli_${VERSION}_x86_64_fedora.rpm
831833
- echo ${NEXUS_PATH_BRANCH_UPLOAD}/linux/windscribe_${VERSION}_x86_64_opensuse.rpm
@@ -846,7 +848,9 @@ build:artifact:links:tagged:
846848
- echo ${NEXUS_PATH_TAGGED_UPLOAD}/${TAG}/Windscribe_${VERSION}_arm64.exe
847849
- echo ${NEXUS_PATH_TAGGED_UPLOAD}/${TAG}/Windscribe_$VERSION.dmg
848850
- echo ${NEXUS_PATH_TAGGED_UPLOAD}/${TAG}/windscribe_${VERSION}_amd64.deb
851+
- echo ${NEXUS_PATH_TAGGED_UPLOAD}/${TAG}/windscribe_${VERSION}_arm64.deb
849852
- echo ${NEXUS_PATH_TAGGED_UPLOAD}/${TAG}/windscribe-cli_${VERSION}_amd64.deb
853+
- echo ${NEXUS_PATH_TAGGED_UPLOAD}/${TAG}/windscribe-cli_${VERSION}_arm64.deb
850854
- echo ${NEXUS_PATH_TAGGED_UPLOAD}/${TAG}/windscribe_${VERSION}_x86_64_fedora.rpm
851855
- echo ${NEXUS_PATH_TAGGED_UPLOAD}/${TAG}/windscribe-cli_${VERSION}_x86_64_fedora.rpm
852856
- echo ${NEXUS_PATH_TAGGED_UPLOAD}/${TAG}/windscribe_${VERSION}_x86_64_opensuse.rpm

backend/mac/helper/helper-info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<key>CFBundleName</key>
1010
<string>WindscribeHelper</string>
1111
<key>CFBundleVersion</key>
12-
<string>73</string>
12+
<string>76</string>
1313
<key>NSHumanReadableCopyright</key>
1414
<string>Copyright © 2024 Windscribe Limited. All rights reserved.</string>
1515
<key>LSMinimumSystemVersion</key>

backend/mac/helper/installer/files.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ int Files::executeStep()
2626

2727
// The installer should have removed any existing Windscribe app instance by this point,
2828
// but we'll doublecheck just to be sure.
29-
if (std::filesystem::exists(installPath)) {
29+
std::error_code ec;
30+
if (std::filesystem::exists(installPath, ec)) {
3031
LOG("Files: install path already exists");
31-
std::filesystem::remove_all(installPath);
32+
std::filesystem::remove_all(installPath, ec);
33+
if (ec) {
34+
LOG("Files: filesystem::remove_all failed: %s", ec.message().c_str());
35+
return -1;
36+
}
3237
}
3338

3439
auto status = Utils::executeCommand("mkdir", {installPath.c_str()}, &lastError_);

backend/mac/helper/ip_hostnames/ares_library_init.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ AresLibraryInit::~AresLibraryInit()
1919
void AresLibraryInit::init()
2020
{
2121
if (!init_ && !failedInit_) {
22-
int status = ares_library_init(ARES_LIB_INIT_ALL);
23-
if (status != ARES_SUCCESS) {
24-
Logger::instance().out("ares_library_init failed: %s", ares_strerror(status));
25-
failedInit_ = true;
26-
} else {
27-
init_ = true;
28-
}
22+
int status = ares_library_init(ARES_LIB_INIT_ALL);
23+
if (status != ARES_SUCCESS) {
24+
Logger::instance().out("ares_library_init failed: %s", ares_strerror(status));
25+
failedInit_ = true;
26+
} else {
27+
init_ = true;
28+
}
2929
}
3030
}

backend/mac/helper/ip_hostnames/dns_resolver.cpp

Lines changed: 115 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@
99

1010
DnsResolver *DnsResolver::this_ = NULL;
1111

12-
DnsResolver::DnsResolver() : channel_(NULL)
12+
DnsResolver::DnsResolver()
13+
: bStopCalled_(false)
14+
, bNeedFinish_(false)
15+
, channel_(NULL)
1316
{
1417
assert(this_ == NULL);
1518
this_ = this;
1619
aresLibraryInit_.init();
20+
21+
thread_ = std::thread(threadFunc, this);
1722
}
1823

1924
DnsResolver::~DnsResolver()
2025
{
21-
cancelAll();
26+
assert(bStopCalled_);
2227
this_ = NULL;
2328
}
2429

@@ -31,106 +36,159 @@ void DnsResolver::setResolveDomainsCallbackHandler(std::function<void(std::map<s
3136
void DnsResolver::stop()
3237
{
3338
cancelAll();
39+
40+
// kick thread
41+
this_->mutex_.lock();
42+
bNeedFinish_ = true;
43+
waitCondition_.notify_all();
44+
this_->mutex_.unlock();
45+
46+
// wait for thread to finish
47+
thread_.join();
48+
bStopCalled_ = true;
3449
}
3550

3651
void DnsResolver::resolveDomains(const std::vector<std::string> &hostnames)
3752
{
3853
std::lock_guard<std::mutex> lock(mutex_);
3954

40-
// cancel any lookups currently in channel
41-
if (!hostnamesInProgress_.empty()) {
42-
ares_cancel(channel_);
43-
ares_destroy(channel_);
44-
ares_queue_wait_empty(channel_, -1);
45-
this_->channel_ = NULL;
46-
} else {
47-
assert(channel_ == NULL);
48-
}
49-
hostnamesInProgress_.clear();
50-
hostinfoResults_.clear();
51-
52-
struct ares_options options;
53-
int optmask = 0;
54-
memset(&options, 0, sizeof(options));
55-
optmask |= ARES_OPT_TRIES;
56-
options.tries = 3;
57-
optmask |= ARES_OPT_EVENT_THREAD;
58-
options.evsys = ARES_EVSYS_DEFAULT;
59-
optmask |= ARES_OPT_MAXTIMEOUTMS;
60-
options.maxtimeout = 5 * 1000;
61-
62-
int status = ares_init_options(&channel_, &options, optmask);
63-
if (status != ARES_SUCCESS) {
64-
Logger::instance().out("ares_init_options failed: %s", ares_strerror(status));
65-
return;
66-
}
55+
{
56+
// cancel any lookups currently in channel
57+
if (!hostnamesInProgress_.empty())
58+
{
59+
ares_cancel(channel_);
60+
ares_destroy(channel_);
61+
this_->channel_ = NULL;
62+
}
63+
else
64+
{
65+
assert(channel_ == NULL);
66+
}
67+
hostnamesInProgress_.clear();
68+
hostinfoResults_.clear();
69+
70+
struct ares_options options;
71+
int optmask = 0;
72+
memset(&options, 0, sizeof(options));
73+
optmask |= ARES_OPT_TRIES;
74+
options.tries = 3;
75+
76+
int status = ares_init_options(&channel_, &options, optmask);
77+
if (status != ARES_SUCCESS)
78+
{
79+
Logger::instance().out("ares_init_options failed: %s", ares_strerror(status));
80+
return;
81+
}
6782

68-
for (auto &hostname : hostnames) {
69-
hostnamesInProgress_.insert(hostname);
70-
}
83+
for (auto &hostname : hostnames)
84+
{
85+
hostnamesInProgress_.insert(hostname);
86+
}
7187

72-
// filter for unique hostnames and execute request
73-
for (auto &hostname : hostnames) {
74-
USER_ARG *userArg = new USER_ARG();
75-
userArg->hostname = hostname;
76-
struct ares_addrinfo_hints hints;
77-
memset(&hints, 0, sizeof(hints));
78-
hints.ai_family = AF_INET;
79-
ares_getaddrinfo(channel_, hostname.c_str(), NULL, &hints, aresLookupFinishedCallback, userArg);
88+
// filter for unique hostnames and execute request
89+
for (auto &hostname : hostnames)
90+
{
91+
USER_ARG *userArg = new USER_ARG();
92+
userArg->hostname = hostname;
93+
ares_gethostbyname(channel_, hostname.c_str(), AF_INET, aresLookupFinishedCallback, userArg);
94+
}
8095
}
96+
97+
// kick thread
98+
waitCondition_.notify_all();
8199
}
82100

83101
void DnsResolver::cancelAll()
84102
{
85103
std::lock_guard<std::mutex> lock(mutex_);
86-
87-
if (channel_) {
104+
if (channel_)
105+
{
88106
ares_cancel(channel_);
89107
hostnamesInProgress_.clear();
90108
ares_destroy(channel_);
91-
ares_queue_wait_empty(channel_, -1);
92109
}
93110
channel_ = NULL;
94111
}
95112

96-
void DnsResolver::aresLookupFinishedCallback(void * arg, int status, int /*timeouts*/, struct ares_addrinfo *result)
97-
{
98-
if (this_ == nullptr) {
99-
assert(false);
100-
return;
101-
};
102-
103-
std::lock_guard<std::mutex> lock(this_->mutex_);
104113

114+
void DnsResolver::aresLookupFinishedCallback(void * arg, int status, int /*timeouts*/, struct hostent * host)
115+
{
105116
USER_ARG *userArg = static_cast<USER_ARG *>(arg);
106117

107118
// cancel and fail cases
108-
if (status == ARES_ECANCELLED) {
119+
if (status == ARES_ECANCELLED)
120+
{
109121
delete userArg;
110122
return;
111123
}
112124

113125
HostInfo hostInfo;
114126
hostInfo.hostname = userArg->hostname;
115127

116-
if (status != ARES_SUCCESS) {
128+
if (status != ARES_SUCCESS)
129+
{
117130
hostInfo.error = true;
118-
} else {
131+
}
132+
else
133+
{
119134
// add ips
120-
for (struct ares_addrinfo_node *node = result->nodes; node != NULL; node = node->ai_next) {
135+
for (char **p = host->h_addr_list; *p; p++)
136+
{
121137
char addr_buf[46] = "??";
122-
ares_inet_ntop(node->ai_family, &((const struct sockaddr_in *)((void *)node->ai_addr))->sin_addr, addr_buf, sizeof(addr_buf));
138+
ares_inet_ntop(host->h_addrtype, *p, addr_buf, sizeof(addr_buf));
123139
hostInfo.addresses.push_back(std::string(addr_buf));
124140
}
125141
}
126142

127143
this_->hostinfoResults_[hostInfo.hostname] = hostInfo;
128144
this_->hostnamesInProgress_.erase(userArg->hostname);
129145

130-
if (this_->hostnamesInProgress_.empty()) {
146+
if (this_->hostnamesInProgress_.empty())
147+
{
131148
this_->resolveDomainsCallback_(this_->hostinfoResults_);
132149
}
133150

134151
delete userArg;
135152
}
136153

154+
void DnsResolver::threadFunc(void *arg)
155+
{
156+
//BIND_CRASH_HANDLER_FOR_THREAD();
157+
DnsResolver *resolver = static_cast<DnsResolver *>(arg);
158+
159+
while (true)
160+
{
161+
{
162+
std::unique_lock<std::mutex> lockWait(resolver->mutex_);
163+
if (resolver->bNeedFinish_)
164+
{
165+
break;
166+
}
167+
168+
if (resolver->channel_ != NULL && !resolver->processChannel(resolver->channel_))
169+
{
170+
resolver->waitCondition_.wait(lockWait);
171+
}
172+
}
173+
sleep(1);
174+
}
175+
}
176+
177+
bool DnsResolver::processChannel(ares_channel channel)
178+
{
179+
fd_set read_fds, write_fds;
180+
int res;
181+
int nfds;
182+
183+
FD_ZERO(&read_fds);
184+
FD_ZERO(&write_fds);
185+
nfds = ares_fds(channel, &read_fds, &write_fds);
186+
if (nfds == 0) {
187+
return false;
188+
}
189+
timeval tv;
190+
timeval *tvp = ares_timeout(channel, NULL, &tv);
191+
res = select(nfds, &read_fds, &write_fds, NULL, tvp);
192+
ares_process(channel, &read_fds, &write_fds);
193+
return true;
194+
}

backend/mac/helper/ip_hostnames/dns_resolver.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#include <condition_variable>
44
#include <functional>
55
#include <map>
6+
#include <mutex>
67
#include <set>
78
#include <string>
9+
#include <thread>
810
#include <vector>
911

1012
#include "ares_library_init.h"
@@ -36,18 +38,28 @@ class DnsResolver
3638
private:
3739
std::function<void(std::map<std::string, HostInfo>)> resolveDomainsCallback_;
3840

39-
struct USER_ARG {
41+
struct USER_ARG
42+
{
4043
std::string hostname;
4144
};
4245

46+
bool bStopCalled_;
47+
std::mutex mutex_;
48+
std::condition_variable waitCondition_;
49+
bool bNeedFinish_;
50+
4351
AresLibraryInit aresLibraryInit_;
4452
ares_channel channel_;
45-
std::mutex mutex_;
4653

4754
static DnsResolver *this_;
4855

4956
std::map<std::string, HostInfo> hostinfoResults_;
5057
std::set<std::string> hostnamesInProgress_;
5158

52-
static void aresLookupFinishedCallback(void *arg, int status, int timeouts, struct ares_addrinfo *result);
59+
// thread specific
60+
std::thread thread_;
61+
static void threadFunc(void *arg);
62+
static void aresLookupFinishedCallback(void *arg, int status, int timeouts, struct hostent *host);
63+
64+
bool processChannel(ares_channel channel);
5365
};

0 commit comments

Comments
 (0)