| 142 | } |
| 143 | |
| 144 | std::string executeTaskKill(const std::string &pars) |
| 145 | { |
| 146 | CmdKillTarget target; |
| 147 | deserializePars(pars, target); |
| 148 | |
| 149 | bool success = false; |
| 150 | if (target == kTargetApp) { |
| 151 | spdlog::info("Killing " WS_PRODUCT_NAME " processes"); |
| 152 | Utils::executeCommand("pkill", {WS_APP_EXECUTABLE_NAME}); |
| 153 | #ifdef WS_IS_WINDSCRIBE |
| 154 | Utils::executeCommand("pkill", {WS_APP_IDENTIFIER "Engine"}); // For older 1.x clients |
| 155 | #endif |
| 156 | success = true; |
| 157 | } else if (target == kTargetOpenVpn) { |
| 158 | spdlog::info("Killing OpenVPN processes"); |
| 159 | const std::vector<std::string> exes = Utils::getOpenVpnExeNames(); |
| 160 | for (const auto &exe : exes) { |
| 161 | Utils::executeCommand("pkill", {"-f", exe.c_str()}); |
| 162 | } |
| 163 | success = true; |
| 164 | } else if (target == kTargetStunnel) { |
| 165 | spdlog::info("Killing Stunnel processes"); |
| 166 | Utils::executeCommand("pkill", {"-f", WS_PRODUCT_NAME_LOWER "wstunnel"}); |
| 167 | success = true; |
| 168 | } else if (target == kTargetWStunnel) { |
| 169 | spdlog::info("Killing WStunnel processes"); |
| 170 | Utils::executeCommand("pkill", {"-f", WS_PRODUCT_NAME_LOWER "wstunnel"}); |
| 171 | success = true; |
| 172 | } else if (target == kTargetWireGuard) { |
| 173 | spdlog::info("Killing WireGuard processes"); |
| 174 | Utils::executeCommand("pkill", {"-f", WS_PRODUCT_NAME_LOWER "wireguard"}); |
| 175 | success = true; |
| 176 | } else if (target == kTargetCtrld) { |
| 177 | spdlog::info("Killing ctrld processes"); |
| 178 | Utils::executeCommand("pkill", {"-f", WS_PRODUCT_NAME_LOWER "ctrld"}); |
| 179 | success = true; |
| 180 | } else { |
| 181 | spdlog::error("Did not kill processes for type {}", (int)target); |
| 182 | success = false; |
| 183 | } |
| 184 | return serializeResult(success); |
| 185 | } |
| 186 | |
| 187 | std::string startWireGuard(const std::string &pars) |
| 188 | { |
no test coverage detected