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

Function configureWireGuard

src/helper/macos/process_command.cpp:201–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201std::string configureWireGuard(const std::string &pars)
202{
203 std::string clientPrivateKey, clientIpAddress, clientDnsAddressList, peerPublicKey,
204 peerPresharedKey, peerEndpoint, allowedIps;
205 uint16_t listenPort;
206 CmdDnsManager dnsManager;
207 AmneziawgConfig amneziawgConfig;
208 deserializePars(pars, clientPrivateKey, clientIpAddress, clientDnsAddressList, peerPublicKey,
209 peerPresharedKey, peerEndpoint, allowedIps, listenPort, dnsManager, amneziawgConfig);
210
211 bool success = false;
212 if (WireGuardController::instance().isInitialized()) {
213 do {
214 std::vector<std::string> allowed_ips_vector = WireGuardController::instance().splitAndDeduplicateAllowedIps(allowedIps);
215 if (allowed_ips_vector.size() < 1) {
216 spdlog::error("WireGuard: invalid AllowedIps \"{}\"", allowedIps);
217 break;
218 }
219
220 if (!Validation::validateWireGuardConfig(clientIpAddress, clientDnsAddressList, allowed_ips_vector, peerEndpoint)) {
221 spdlog::error("WireGuard: IP validation failed, rejecting config");
222 break;
223 }
224
225 if (!WireGuardController::instance().configureAdapter(clientIpAddress,
226 clientDnsAddressList,
227 MacUtils::resourcePath() + "/dns.sh",
228 allowed_ips_vector)) {
229 spdlog::error("WireGuard: configureAdapter() failed");
230 break;
231 }
232
233 if (!WireGuardController::instance().configureDefaultRouteMonitor(peerEndpoint)) {
234 spdlog::error("WireGuard: configureDefaultRouteMonitor() failed");
235 break;
236 }
237 if (!WireGuardController::instance().configure(clientPrivateKey,
238 peerPublicKey, peerPresharedKey,
239 peerEndpoint, allowed_ips_vector,
240 listenPort, amneziawgConfig)) {
241 spdlog::error("WireGuard: configureDaemon() failed");
242 break;
243 }
244 success = true;
245 } while (0);
246 }
247 return serializeResult(success);
248}
249
250std::string getWireGuardStatus(const std::string &pars)
251{

Callers

nothing calls this directly

Calls 9

deserializeParsFunction · 0.85
validateWireGuardConfigFunction · 0.85
serializeResultFunction · 0.85
isInitializedMethod · 0.45
sizeMethod · 0.45
configureAdapterMethod · 0.45
configureMethod · 0.45

Tested by

no test coverage detected