Skip to content

Commit aaa9dc5

Browse files
committed
v2.17.3
1 parent f7727a5 commit aaa9dc5

File tree

68 files changed

+362
-4923
lines changed

Some content is hidden

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

68 files changed

+362
-4923
lines changed

backend/linux/helper/firewallcontroller.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313

1414
FirewallController::FirewallController() : connected_(false), splitTunnelEnabled_(false), splitTunnelExclude_(true)
1515
{
16-
// If firewall on boot is enabled, restore boot rules
17-
if (Utils::isFileExists("/etc/windscribe/boot_rules.v4")) {
18-
Utils::executeCommand("iptables-restore", {"-n", "/etc/windscribe/boot_rules.v4"});
19-
}
20-
if (Utils::isFileExists("/etc/windscribe/boot_rules.v6")) {
21-
Utils::executeCommand("ip6tables-restore", {"-n", "/etc/windscribe/boot_rules.v6"});
22-
}
2316
}
2417

2518
FirewallController::~FirewallController()
@@ -31,9 +24,9 @@ bool FirewallController::enable(bool ipv6, const std::string &rules)
3124
int fd;
3225

3326
if (ipv6) {
34-
fd = open("/etc/windscribe/rules.v6", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
27+
fd = open("/var/run/windscribe/rules.v6", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
3528
} else {
36-
fd = open("/etc/windscribe/rules.v4", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
29+
fd = open("/var/run/windscribe/rules.v4", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
3730
}
3831

3932
if (fd < 0) {
@@ -49,9 +42,9 @@ bool FirewallController::enable(bool ipv6, const std::string &rules)
4942
}
5043

5144
if (ipv6) {
52-
Utils::executeCommand("ip6tables-restore", {"-n", "/etc/windscribe/rules.v6"});
45+
Utils::executeCommand("ip6tables-restore", {"-n", "/var/run/windscribe/rules.v6"});
5346
} else {
54-
Utils::executeCommand("iptables-restore", {"-n", "/etc/windscribe/rules.v4"});
47+
Utils::executeCommand("iptables-restore", {"-n", "/var/run/windscribe/rules.v4"});
5548
}
5649

5750
// reapply split tunneling rules if necessary
@@ -67,10 +60,10 @@ void FirewallController::getRules(bool ipv6, std::string *outRules)
6760
std::string filename;
6861

6962
if (ipv6) {
70-
filename = "/etc/windscribe/rules.v6";
63+
filename = "/var/run/windscribe/rules.v6";
7164
Utils::executeCommand("ip6tables-save", {"-f", filename.c_str()});
7265
} else {
73-
filename = "/etc/windscribe/rules.v4";
66+
filename = "/var/run/windscribe/rules.v4";
7467
Utils::executeCommand("iptables-save", {"-f", filename.c_str()});
7568
}
7669

@@ -87,8 +80,8 @@ bool FirewallController::enabled(const std::string &tag)
8780

8881
void FirewallController::disable()
8982
{
90-
Utils::executeCommand("rm", {"-f", "/etc/windscribe/rules.v4"});
91-
Utils::executeCommand("rm", {"-f", "/etc/windscribe/rules.v6"});
83+
Utils::executeCommand("rm", {"-f", "/var/run/windscribe/rules.v4"});
84+
Utils::executeCommand("rm", {"-f", "/var/run/windscribe/rules.v6"});
9285
}
9386

9487
void FirewallController::setSplitTunnelingEnabled(bool isConnected, bool isEnabled, bool isExclude, const std::string &defaultAdapter, const std::string &defaultAdapterIp)

backend/linux/helper/firewallonboot.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@
88

99
FirewallOnBootManager::FirewallOnBootManager(): comment_("Windscribe client rule")
1010
{
11+
// Migrate old boot rules if necessary
12+
if (Utils::isFileExists("/etc/windscribe/boot_rules.v4")) {
13+
Utils::executeCommand("mv", {"/etc/windscribe/boot_rules.v4", "/var/tmp/windscribe/boot_rules.v4"});
14+
Utils::executeCommand("rm", {"/etc/windscribe/rules.v4"});
15+
}
16+
if (Utils::isFileExists("/etc/windscribe/boot_rules.v6")) {
17+
Utils::executeCommand("mv", {"/etc/windscribe/boot_rules.v6", "/var/tmp/windscribe/boot_rules.v6"});
18+
Utils::executeCommand("rm", {"/etc/windscribe/rules.v6"});
19+
}
20+
21+
// If firewall on boot is enabled, restore boot rules
22+
if (Utils::isFileExists("/var/tmp/windscribe/boot_rules.v4")) {
23+
Utils::executeCommand("iptables-restore", {"-n", "/var/tmp/windscribe/boot_rules.v4"});
24+
}
25+
if (Utils::isFileExists("/var/tmp/windscribe/boot_rules.v6")) {
26+
Utils::executeCommand("ip6tables-restore", {"-n", "/var/tmp/windscribe/boot_rules.v6"});
27+
}
1128
}
1229

1330
FirewallOnBootManager::~FirewallOnBootManager()
@@ -78,7 +95,7 @@ bool FirewallOnBootManager::enable(bool allowLanTraffic) {
7895
rules << "COMMIT\n";
7996

8097
// write rules
81-
int fd = open("/etc/windscribe/boot_rules.v4", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
98+
int fd = open("/var/tmp/windscribe/boot_rules.v4", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
8299
if (fd < 0) {
83100
spdlog::error("Could not open boot firewall rules for writing");
84101
return false;
@@ -103,7 +120,7 @@ bool FirewallOnBootManager::enable(bool allowLanTraffic) {
103120
rules << "COMMIT\n";
104121

105122
// write rules
106-
fd = open("/etc/windscribe/boot_rules.v6", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
123+
fd = open("/var/tmp/windscribe/boot_rules.v6", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
107124
if (fd < 0) {
108125
spdlog::error("Could not open v6 boot firewall rules for writing");
109126
return false;
@@ -118,7 +135,7 @@ bool FirewallOnBootManager::enable(bool allowLanTraffic) {
118135

119136
bool FirewallOnBootManager::disable()
120137
{
121-
Utils::executeCommand("rm", {"-f", "/etc/windscribe/boot_rules.v4"});
122-
Utils::executeCommand("rm", {"-f", "/etc/windscribe/boot_rules.v6"});
138+
Utils::executeCommand("rm", {"-f", "/var/tmp/windscribe/boot_rules.v4"});
139+
Utils::executeCommand("rm", {"-f", "/var/tmp/windscribe/boot_rules.v6"});
123140
return true;
124141
}

backend/linux/helper/ovpn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bool writeOVPNFile(const std::string &dnsScript, unsigned int port, const std::s
1515
std::string line;
1616
int bytes;
1717

18-
int fd = open("/etc/windscribe/config.ovpn", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
18+
int fd = open("/var/run/windscribe/config.ovpn", O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
1919
if (fd < 0) {
2020
spdlog::error("Could not open config for writing");
2121
return false;

backend/linux/helper/process_command.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ std::string executeOpenVPN(const std::string &pars)
103103
return serializeResult(false, cmdId);
104104
}
105105

106-
std::string fullCmd = Utils::getFullCommand(Utils::getExePath(), "windscribeopenvpn", "--config /etc/windscribe/config.ovpn");
106+
std::string fullCmd = Utils::getFullCommand(Utils::getExePath(), "windscribeopenvpn", "--config /var/run/windscribe/config.ovpn");
107107
if (fullCmd.empty()) {
108108
// Something wrong with the command
109109
return serializeResult(false, cmdId);
@@ -116,7 +116,7 @@ std::string executeOpenVPN(const std::string &pars)
116116
return serializeResult(false, cmdId);
117117
} else {
118118

119-
cmdId = ExecuteCmd::instance().execute(fullCmd, "/etc/windscribe");
119+
cmdId = ExecuteCmd::instance().execute(fullCmd, "/opt/windscribe");
120120
return serializeResult(true, cmdId);
121121
}
122122
}
@@ -463,7 +463,7 @@ std::string setDnsLeakProtectEnabled(const std::string &pars)
463463
spdlog::debug("Set DNS leak protect: {}", enabled ? "enabled" : "disabled");
464464
// We only handle the down case; the 'up' trigger for this script happens in the DNS manager script
465465
if (!enabled) {
466-
Utils::executeCommand("/etc/windscribe/dns-leak-protect", {"down"});
466+
Utils::executeCommand("/opt/windscribe/scripts/dns-leak-protect", {"down"});
467467
}
468468
return std::string();
469469
}

backend/linux/helper/server.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <unistd.h>
1616
#include <spdlog/spdlog.h>
1717

18-
#include "firewallcontroller.h"
18+
#include "firewallonboot.h"
1919
#include "ipc/helper_security.h"
2020
#include "process_command.h"
2121
#include "utils.h"
@@ -171,10 +171,11 @@ void Server::run()
171171

172172
#ifdef NDEBUG // release build
173173
Utils::createWindscribeUserAndGroup();
174-
auto res = system("mkdir -p /var/run/windscribe && chown :windscribe /var/run/windscribe && chmod 775 /var/run/windscribe"); // res is necessary to avoid no-discard warning.
174+
auto res = system("mkdir -p /var/run/windscribe && chown :windscribe /var/run/windscribe && chmod 775 /var/run/windscribe && mkdir -p /var/tmp/windscribe"); // res is necessary to avoid no-discard warning.
175175
#else // debug build
176-
auto res = system("mkdir -p /var/run/windscribe && chmod 777 /var/run/windscribe");
176+
auto res = system("mkdir -p /var/run/windscribe && chmod 777 /var/run/windscribe && mkdir -p /var/tmp/windscribe");
177177
#endif
178+
spdlog::info("/var/run/windscribe and /var/tmp/windscribe created");
178179
UNUSED(res);
179180

180181
::unlink(SOCK_PATH);
@@ -198,8 +199,9 @@ void Server::run()
198199
}
199200
#endif
200201

201-
// Cause the FirewallController to be constructed here, so that on-boot rules are processed, even if the Windscribe app/service does not start.
202-
FirewallController::instance();
202+
// Cause the FireallOnBootManager to be constructed here, so that on-boot rules are processed,
203+
// even if the Windscribe app/service does not start.
204+
FirewallOnBootManager::instance();
203205

204206
startAccept();
205207

backend/linux/helper/split_tunneling/cgroups.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bool CGroups::enable(const ConnectStatus &connectStatus, bool isAllowLanTraffic,
1919

2020
std::string out;
2121

22-
int ret = Utils::executeCommand("/etc/windscribe/cgroups-up",
22+
int ret = Utils::executeCommand("/opt/windscribe/scripts/cgroups-up",
2323
{ mark_.c_str(),
2424
connectStatus.defaultAdapter.gatewayIp,
2525
connectStatus.defaultAdapter.adapterName,
@@ -42,7 +42,7 @@ void CGroups::disable()
4242
{
4343
spdlog::debug("cgroups disable");
4444

45-
Utils::executeCommand("/etc/windscribe/cgroups-down");
45+
Utils::executeCommand("/opt/windscribe/scripts/cgroups-down");
4646
}
4747

4848
void CGroups::addApp(pid_t pid)

backend/linux/helper/utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ std::string getDnsScript(CmdDnsManager mgr)
134134
{
135135
switch(mgr) {
136136
case kSystemdResolved:
137-
return "/etc/windscribe/update-systemd-resolved";
137+
return "/opt/windscribe/scripts/update-systemd-resolved";
138138
case kResolvConf:
139-
return "/etc/windscribe/update-resolv-conf";
139+
return "/opt/windscribe/scripts/update-resolv-conf";
140140
case kNetworkManager:
141-
return "/etc/windscribe/update-network-manager";
141+
return "/opt/windscribe/scripts/update-network-manager";
142142
default:
143143
return "";
144144
}

client/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,8 @@ endif()
185185

186186
target_link_libraries(Windscribe PRIVATE ${CLIENT_LIBS} engine common wsnet::wsnet spdlog::spdlog Qt6::Network ${OS_SPECIFIC_LIBRARIES})
187187

188-
# Wayland support on Linux
189188
if (UNIX AND (NOT APPLE))
190-
qt_import_plugins(Windscribe INCLUDE Qt6::QWaylandIntegrationPlugin)
189+
qt_import_plugins(Windscribe INCLUDE Qt6::QWaylandIntegrationPlugin Qt6::QXcbIntegrationPlugin)
191190
endif()
192191

193192
target_include_directories(Windscribe PRIVATE

client/common/api_responses/portmap.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ namespace api_responses {
1111

1212
PortMap::PortMap(const std::string &json) : d(new PortMapData)
1313
{
14+
if (json.empty()) {
15+
return;
16+
}
17+
1418
QJsonParseError errCode;
1519
auto doc = QJsonDocument::fromJson(QByteArray(json.c_str()), &errCode);
20+
if (errCode.error != QJsonParseError::ParseError::NoError) {
21+
return;
22+
}
23+
1624
auto jsonObject = doc.object();
1725
auto jsonData = jsonObject["data"].toObject();
1826
auto jsonArray = jsonData["portmap"].toArray();
@@ -42,6 +50,10 @@ PortMap::PortMap(const std::string &json) : d(new PortMapData)
4250
d->items_ << portItem;
4351
}
4452
removeUnsupportedProtocols(types::Protocol::supportedProtocols());
53+
54+
if (d->items_.count() > 0) {
55+
isValid_ = true;
56+
}
4557
}
4658

4759
int PortMap::getPortItemCount() const
@@ -130,6 +142,11 @@ void PortMap::removeUnsupportedProtocols(const QList<types::Protocol> &supported
130142
}), d->items_.end());
131143
}
132144

145+
bool PortMap::isValid() const
146+
{
147+
return isValid_;
148+
}
149+
133150
QDataStream& operator <<(QDataStream& stream, const PortItem& p)
134151
{
135152
stream << p.versionForSerialization_;
@@ -153,7 +170,7 @@ QDataStream& operator >>(QDataStream& stream, PortItem& p)
153170
QDataStream& operator <<(QDataStream& stream, const PortMap& p)
154171
{
155172
stream << p.versionForSerialization_;
156-
stream << p.d->items_;
173+
stream << p.d->items_ << p.isValid_;
157174
return stream;
158175
}
159176

@@ -167,6 +184,9 @@ QDataStream& operator >>(QDataStream& stream, PortMap& p)
167184
return stream;
168185
}
169186
stream >> p.d->items_;
187+
if (version >= 2) {
188+
stream >> p.isValid_;
189+
}
170190
return stream;
171191
}
172192

client/common/api_responses/portmap.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class PortMap
4141
public:
4242
PortMap() : d(new PortMapData) {}
4343
explicit PortMap(const std::string &json);
44-
PortMap(const PortMap &other) : d (other.d) {}
44+
PortMap(const PortMap &other) : d (other.d), isValid_(other.isValid()) {}
4545

4646
int getPortItemCount() const;
4747
const PortItem *getPortItemByIndex(int ind) const;
@@ -54,6 +54,8 @@ class PortMap
5454

5555
void removeUnsupportedProtocols(const QList<types::Protocol> &supportedProtocols);
5656

57+
bool isValid() const;
58+
5759
PortMap& operator=(const PortMap&) = default;
5860

5961
friend QDataStream& operator <<(QDataStream& stream, const PortMap& p);
@@ -62,7 +64,9 @@ class PortMap
6264

6365
private:
6466
QSharedDataPointer<PortMapData> d;
65-
static constexpr quint32 versionForSerialization_ = 1;
67+
bool isValid_ = false;
68+
69+
static constexpr quint32 versionForSerialization_ = 2;
6670
};
6771

6872
} //namespace api_responses

0 commit comments

Comments
 (0)