MCPcopy Create free account
hub / github.com/Windscribe/Desktop-App / startCtrld

Function startCtrld

src/helper/linux/process_command.cpp:272–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272std::string startCtrld(const std::string &pars)
273{
274 std::string upstream1, upstream2;
275 std::vector<std::string> domains;
276 bool isCreateLog;
277 deserializePars(pars, upstream1, upstream2, domains, isCreateLog);
278
279
280 spdlog::debug("Starting ctrld");
281
282 // Validate URLs
283 if (upstream1.empty() || Validation::normalizeAddress(upstream1).empty() || (!upstream2.empty() && Validation::normalizeAddress(upstream2).empty())) {
284 spdlog::error("Invalid upstream URL(s)");
285 return serializeResult(false);
286 }
287 for (const auto &domain: domains) {
288 if (!Validation::isValidDomain(domain)) {
289 spdlog::error("Invalid domain: {}", domain);
290 return serializeResult(false);
291 }
292 }
293
294 std::string ctrldPath;
295 if (!Utils::resolveExePath(Utils::getExePath(), WS_PRODUCT_NAME_LOWER "ctrld", ctrldPath)) {
296 return serializeResult(false);
297 }
298
299 std::vector<std::string> args = {"run", "--daemon", "--listen=127.0.0.1:53",
300 "--primary_upstream=" + upstream1};
301 if (!upstream2.empty()) {
302 args.push_back("--secondary_upstream=" + upstream2);
303 if (!domains.empty()) {
304 std::string domainsStr;
305 for (size_t i = 0; i < domains.size(); ++i) {
306 if (i > 0) domainsStr += ",";
307 domainsStr += domains[i];
308 }
309 args.push_back("--domains=" + domainsStr);
310 }
311 }
312 if (isCreateLog) {
313 args.push_back("--log");
314 args.push_back(WS_LINUX_LOG_DIR "/ctrld.log");
315 args.push_back("-vv");
316 }
317
318 bool executed = Utils::executeCommand(ctrldPath, args) == 0;
319 return serializeResult(executed);
320}
321
322std::string checkFirewallState(const std::string &pars)
323{

Callers

nothing calls this directly

Calls 8

deserializeParsFunction · 0.85
normalizeAddressFunction · 0.85
serializeResultFunction · 0.85
isValidDomainFunction · 0.85
resolveExePathFunction · 0.70
getExePathFunction · 0.70
executeCommandFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected