Skip to content

Commit

Permalink
v2.13.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bernerdad committed Dec 2, 2024
1 parent 59e7537 commit 2b5d198
Show file tree
Hide file tree
Showing 299 changed files with 24,229 additions and 23,839 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Use default line ending for Git (LF)
* text=auto

# Except in tools/vcpkg, as this dir contains patches that should retain their line endings.
tools/vcpkg/**/* -text
# Except in installer/windows/additional_files, as this dir contains *.inf files that should retain their line endings.
installer/windows/additional_files/**/* -text
5 changes: 3 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ test:wsnet:mac:
GIT_STRATEGY: clone
script:
- !reference [.build_mac_installer_common, script]
- tools/build_all --build-app --build-tests
- tools/build_all --static-analysis --build-app --build-tests
- !reference [.run_tests_posix, script]

after_script:
Expand All @@ -948,7 +948,8 @@ test:wsnet:rhel:
script:
- OS_IDENTIFIER="linux"
- !reference [.build_linux_installer_common, script]
- tools/build_all --build-app --build-tests
- python3 -m pip install clang-tidy
- tools/build_all --static-analysis --build-app --build-tests
- !reference [.run_tests_posix, script]

after_script:
Expand Down
8 changes: 8 additions & 0 deletions backend/linux/helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ if(DEFINE_USE_SIGNATURE_CHECK_MACRO)
add_definitions(-DUSE_SIGNATURE_CHECK)
endif(DEFINE_USE_SIGNATURE_CHECK_MACRO)

if(UNIX AND (NOT APPLE))
# if build requested a headless client, set the necessary definitions
option(DEFINE_CLI_ONLY_MACRO "Build GUI-less client" OFF)
if(DEFINE_CLI_ONLY_MACRO)
add_definitions(-DCLI_ONLY)
endif(DEFINE_CLI_ONLY_MACRO)
endif()

project(helper)

find_package(Boost REQUIRED COMPONENTS serialization thread filesystem)
Expand Down
7 changes: 7 additions & 0 deletions backend/linux/helper/process_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ CMD_ANSWER setMacAddress(boost::archive::text_iarchive &ia)
// reset addresses on other networks
Utils::resetMacAddresses(cmd.network);

#ifdef CLI_ONLY
// Must bring interface down to change the MAC address
Utils::executeCommand("ip", {"link", "set", "dev", cmd.interface, "down"});
Utils::executeCommand("ip", {"link", "set", "dev", cmd.interface, "address", mac});
Utils::executeCommand("ip", {"link", "set", "dev", cmd.interface, "up"});
#else
std::string out;
if (cmd.isWifi) {
Utils::executeCommand("nmcli", {"connection", "modify", cmd.network.c_str(), "wifi.cloned-mac-address", mac.c_str()}, &out);
Expand All @@ -342,6 +348,7 @@ CMD_ANSWER setMacAddress(boost::archive::text_iarchive &ia)
}
// restart the connection
Utils::executeCommand("nmcli", {"connection", "up", cmd.network.c_str()});
#endif
answer.executed = 1;
return answer;
}
Expand Down
79 changes: 79 additions & 0 deletions backend/linux/helper/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,86 @@ bool isMacAddressSpoofed(const std::string &network)
return false;
}

#ifdef CLI_ONLY
static std::vector<std::string> getInterfaceNames()
{
std::string output;
std::string line;
std::vector<std::string> interfaces;

Utils::executeCommand("ip", {"link"}, &output);

std::stringstream is(output);
while (std::getline(is, line)) {
if (line.empty() || line[0] == ' ') {
continue;
}

// Interface name is between the first space and the next colon
size_t start = line.find(' ');
if (start == std::string::npos) {
continue;
}
start++; // Move past the space
size_t end = line.find(':', start);
if (end == std::string::npos) {
continue;
}
interfaces.push_back(line.substr(start, end - start));
}

return interfaces;
}

static std::string getHwMac(const std::string &ifname)
{
std::string output;
Utils::executeCommand("ethtool", {"-P", ifname}, &output);

// Address is between the second space and new line
size_t start = output.find(' ', output.find(' ') + 1);
if (start == std::string::npos) {
return "";
}
size_t end = output.find('\n', start);
if (end == std::string::npos) {
return "";
}

return output.substr(start, end - start);
}

static std::string getCurrentMac(const std::string &ifname)
{
std::string output;
Utils::executeCommand("cat", {"/sys/class/net/" + ifname + "/address"}, &output);
// Remove trailing whitespace
output.erase(output.find_last_not_of(" \n\r\t") + 1);
return output;
}
#endif

bool resetMacAddresses(const std::string &ignoreNetwork)
{
#ifdef CLI_ONLY
std::vector<std::string> interfaces = getInterfaceNames();

for (const auto interface : interfaces) {
// skip ignored network
if (interface == "lo" || interface == ignoreNetwork) {
continue;
}

std::string hwAddr = getHwMac(interface);
std::string curAddr = getCurrentMac(interface);
if (hwAddr != curAddr) {
// Must bring down interface to change the MAC address
Utils::executeCommand("ip", {"link", "set", "dev", interface, "down"});
Utils::executeCommand("ip", {"link", "set", "dev", interface, "address", hwAddr});
Utils::executeCommand("ip", {"link", "set", "dev", interface, "up"});
}
}
#else
std::string output;
std::string line;
bool firstline = true;
Expand Down Expand Up @@ -277,6 +355,7 @@ bool resetMacAddresses(const std::string &ignoreNetwork)
Utils::executeCommand("nmcli", {"connection", "up", name.c_str()});
}
}
#endif
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ bool KernelModuleCommunicator::start(const std::string &deviceName)

bool KernelModuleCommunicator::stop()
{
#ifndef CLI_ONLY
// Bring down utun420 via nmcli first, or NetworkManager/GNOME may throw up a scary looking "error".
// This is a workaround for #996; this is not really our bug but it's a bad user experience otherwise.
Utils::executeCommand("nmcli", {"con", "down", deviceName_.c_str()});
#endif

wg_del_device(deviceName_.c_str());
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool WireGuardGoCommunicator::Connection::getOutput(ResultMap *results_map) cons
char prev = 0, c = 0;
for (;;) {
c = static_cast<char>(fgetc(fileHandle_));
if ((c == '\n' && prev == '\n') || feof(fileHandle_)) {
if ((c == '\n' && prev == '\n') || feof(fileHandle_) || ferror(fileHandle_)) {
break;
}
prev = c;
Expand Down
2 changes: 1 addition & 1 deletion backend/mac/helper/helper-info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleName</key>
<string>WindscribeHelper</string>
<key>CFBundleVersion</key>
<string>81</string>
<string>83</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2024 Windscribe Limited. All rights reserved.</string>
<key>LSMinimumSystemVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions backend/mac/helper/process_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ CMD_ANSWER setDnsScriptEnabled(boost::archive::text_iarchive &ia)
CMD_ANSWER answer;
CMD_SET_DNS_SCRIPT_ENABLED cmd;
ia >> cmd;
spdlog::info("Set DNS script: %s", cmd.enabled ? "enabled" : "disabled");
spdlog::info("Set DNS script: {}", cmd.enabled ? "enabled" : "disabled");

answer.executed = 1;
std::string out;
Expand Down Expand Up @@ -655,7 +655,7 @@ CMD_ANSWER installerCreateCliSymlink(boost::archive::text_iarchive &ia)
}

spdlog::debug("Creating CLI symlink");
std::string filepath = Utils::getExePath() + "/windscribe-cli";
std::string filepath = Utils::getExePath() + "/../MacOS/windscribe-cli";
std::string sympath = "/usr/local/bin/windscribe-cli";
std::filesystem::remove(sympath, err);
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion backend/mac/helper/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ std::string getFullCommand(const std::string &exePath, const std::string &execut
#endif

std::string fullCmd = std::string(canonicalPath) + "/" + executable + " " + arguments;
spdlog::debug("Resolved command: %s", fullCmd);
spdlog::debug("Resolved command: {}", fullCmd);
free(canonicalPath);

if (fullCmd.find_first_of(";|&`") != std::string::npos) {
Expand Down
2 changes: 1 addition & 1 deletion backend/windows/windscribe_service/process_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ MessagePacketResult wmicGetConfigErrorCode(boost::archive::text_iarchive &ia)
ia >> cmdWmicGetConfigErrorCode;

std::wstring wmicCmd = Utils::getSystemDir() + L"\\wbem\\wmic.exe path win32_networkadapter where description=\"" + cmdWmicGetConfigErrorCode.szAdapterName + L"\" get ConfigManagerErrorCode";
spdlog::debug(L"AA_COMMAND_WMIC_GET_CONFIG_ERROR_CODE, cmd=%s", wmicCmd);
spdlog::debug(L"AA_COMMAND_WMIC_GET_CONFIG_ERROR_CODE, cmd={}", wmicCmd);
return ExecuteCmd::instance().executeBlockingCmd(wmicCmd);
}

Expand Down
2 changes: 1 addition & 1 deletion backend/windows/windscribe_service/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool regGetProperty(HKEY h, const std::wstring& subkeyName, const std::wstring&
nError = RegQueryValueExW(hKey, valueName.c_str(), 0, NULL, value, size);

if (nError != ERROR_SUCCESS) {
spdlog::error(L"Property %s not found for key {}: {}", valueName, subkeyName, nError);
spdlog::error(L"Property {} not found for key {}: {}", valueName, subkeyName, nError);
return false;
}

Expand Down
80 changes: 40 additions & 40 deletions backend/windows/wireguard_service/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
cmake_minimum_required(VERSION 3.23)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(WINDSCRIBE_BUILD_LIBS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../build-libs-arm64)
else()
set(WINDSCRIBE_BUILD_LIBS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../build-libs)
endif()

add_definitions(-DUNICODE -D_UNICODE)

project(wireguard_service)

find_package(spdlog CONFIG REQUIRED)


set(SOURCES
ServiceMain.cpp
wireguard_service.rc
../../../client/common/utils/servicecontrolmanager.cpp
)

add_compile_options("$<$<CONFIG:Release>:/Zi>")
add_link_options("$<$<CONFIG:Release>:/DEBUG>" "$<$<CONFIG:Release>:/OPT:REF>" "$<$<CONFIG:Release>:/OPT:ICF>")

add_executable(WireguardService ${SOURCES})

target_include_directories(WireguardService PRIVATE
../../../client/common
)

target_link_libraries(WireguardService PRIVATE
spdlog::spdlog
)

install(TARGETS WireguardService
RUNTIME DESTINATION .
)
cmake_minimum_required(VERSION 3.23)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(WINDSCRIBE_BUILD_LIBS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../build-libs-arm64)
else()
set(WINDSCRIBE_BUILD_LIBS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../build-libs)
endif()

add_definitions(-DUNICODE -D_UNICODE)

project(wireguard_service)

find_package(spdlog CONFIG REQUIRED)


set(SOURCES
ServiceMain.cpp
wireguard_service.rc
../../../client/common/utils/servicecontrolmanager.cpp
)

add_compile_options("$<$<CONFIG:Release>:/Zi>")
add_link_options("$<$<CONFIG:Release>:/DEBUG>" "$<$<CONFIG:Release>:/OPT:REF>" "$<$<CONFIG:Release>:/OPT:ICF>")

add_executable(WireguardService ${SOURCES})

target_include_directories(WireguardService PRIVATE
../../../client/common
)

target_link_libraries(WireguardService PRIVATE
spdlog::spdlog
)

install(TARGETS WireguardService
RUNTIME DESTINATION .
)
Loading

0 comments on commit 2b5d198

Please sign in to comment.