| 360 | } |
| 361 | |
| 362 | std::string startStunnel(const std::string &pars) |
| 363 | { |
| 364 | std::string hostname; |
| 365 | unsigned int port, localPort; |
| 366 | bool extraPadding; |
| 367 | deserializePars(pars, hostname, port, localPort, extraPadding); |
| 368 | |
| 369 | spdlog::debug("Starting stunnel"); |
| 370 | |
| 371 | if (!Validation::isValidIpv4Address(hostname)) { |
| 372 | return serializeResult(false); |
| 373 | } |
| 374 | |
| 375 | std::string wstunnelPath; |
| 376 | if (!Utils::resolveExePath(Utils::getExePath(), WS_PRODUCT_NAME_LOWER "wstunnel", wstunnelPath)) { |
| 377 | return serializeResult(false); |
| 378 | } |
| 379 | |
| 380 | std::vector<std::string> args = { |
| 381 | "--listenAddress", "127.0.0.1:" + std::to_string(localPort), |
| 382 | "--remoteAddress", "https://" + hostname + ":" + std::to_string(port), |
| 383 | "--logFilePath", "", |
| 384 | }; |
| 385 | if (extraPadding) { |
| 386 | args.push_back("--extraTlsPadding"); |
| 387 | } |
| 388 | args.push_back("--tunnelType"); |
| 389 | args.push_back("2"); |
| 390 | |
| 391 | Spawn::Options opts; |
| 392 | opts.runAsUser = WS_PRODUCT_NAME_LOWER; |
| 393 | return serializeResult(Spawn::spawnDetached(wstunnelPath, args, opts)); |
| 394 | } |
| 395 | |
| 396 | std::string startWstunnel(const std::string &pars) |
| 397 | { |
nothing calls this directly
no test coverage detected