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

Function executeOpenVPN

src/helper/linux/process_command.cpp:95–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95std::string executeOpenVPN(const std::string &pars)
96{
97 std::string config, httpProxy, socksProxy;
98 unsigned int port, httpPort, socksPort;
99 CmdDnsManager dnsManager;
100 deserializePars(pars, config, port, httpProxy, httpPort, socksProxy, socksPort, dnsManager);
101
102 std::string script = Utils::getDnsScript(dnsManager);
103 if (script.empty()) {
104 spdlog::error("Could not find appropriate DNS manager script");
105 return serializeResult(false);
106 }
107
108 // The proxy address must be an IP literal: the GUI restricts it to one (NetworkingValidation::
109 // isIp) and no other path sets it. Validate here too rather than trust the client — an invalid
110 // value is dropped so it can't reach the OpenVPN config the helper writes as root. The proxy
111 // lines are appended after OvpnDirectiveWhitelist::filterConfig, so they aren't otherwise
112 // filtered. isValidIpAddress also rejects whitespace, subsuming the previous whitespace guard.
113 if (!httpProxy.empty() && !Validation::isValidIpAddress(httpProxy)) {
114 spdlog::warn("executeOpenVPN: invalid httpProxy, ignoring");
115 httpProxy = "";
116 }
117 if (!socksProxy.empty() && !Validation::isValidIpAddress(socksProxy)) {
118 spdlog::warn("executeOpenVPN: invalid socksProxy, ignoring");
119 socksProxy = "";
120 }
121
122 if (!OVPN::writeOVPNFile(script, port, config, httpProxy, httpPort, socksProxy, socksPort)) {
123 spdlog::error("Could not write OpenVPN config");
124 return serializeResult(false);
125 }
126
127 std::string ovpnPath;
128 if (!Utils::resolveExePath(Utils::getExePath(), WS_PRODUCT_NAME_LOWER "openvpn", ovpnPath)) {
129 return serializeResult(false);
130 }
131
132 Spawn::Options opts;
133 opts.extraEnv = {{"OPENSSL_CONF", "/dev/null"}};
134 opts.cwd = WS_LINUX_INSTALL_DIR;
135 std::vector<std::string> args = {"--mark", "20310", "--config", WS_LINUX_RUN_DIR "/config.ovpn"};
136 return serializeResult(Spawn::spawnDetached(ovpnPath, args, opts));
137}
138
139std::string setOpenVpnDcoMode(const std::string &pars)
140{

Callers

nothing calls this directly

Calls 8

deserializeParsFunction · 0.85
getDnsScriptFunction · 0.85
serializeResultFunction · 0.85
spawnDetachedFunction · 0.85
writeOVPNFileFunction · 0.70
resolveExePathFunction · 0.70
getExePathFunction · 0.70
isValidIpAddressFunction · 0.50

Tested by

no test coverage detected