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

Method onConnectionManagerConnected

src/client/engine/engine/engine.cpp:1389–1548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1387}
1388
1389void Engine::onConnectionManagerConnected()
1390{
1391 QString adapterName = connectionManager_->getVpnAdapterInfo().adapterName();
1392
1393#ifdef Q_OS_WIN
1394 // wireguard-nt and AmneziaWG services monitor adapter metrics.
1395 if (!connectionManager_->currentProtocol().isWireGuardProtocol()) {
1396 AdapterMetricsController_win::updateMetrics(adapterName, helper_);
1397 }
1398#elif defined (Q_OS_MACOS) || defined (Q_OS_LINUX)
1399 firewallController_->setVpnInterface_posix(adapterName);
1400#endif
1401
1402 bool isFirewallAlreadyEnabled = false;
1403 if (engineSettings_.firewallSettings().mode == FIREWALL_MODE_AUTOMATIC) {
1404 const bool isAllowFirewallAfterConnection =
1405 connectionManager_->isAllowFirewallAfterConnection();
1406
1407 if (isAllowFirewallAfterConnection &&
1408 engineSettings_.firewallSettings().when == FIREWALL_WHEN_AFTER_CONNECTION)
1409 {
1410 if (!firewallController_->firewallActualState())
1411 {
1412 qCDebug(LOG_BASIC) << "Automatic enable firewall after connection";
1413 firewallController_->firewallOn(
1414 connectionManager_->getLastConnectedIp(),
1415 firewallExceptions_.getIPAddressesForFirewallForConnectedState(),
1416 engineSettings_.isAllowLanTraffic(),
1417 locationId_.isCustomConfigsLocation(),
1418 true);
1419 emit firewallStateChanged(true);
1420 isFirewallAlreadyEnabled = true;
1421 }
1422 }
1423 else if (!isAllowFirewallAfterConnection &&
1424 engineSettings_.firewallSettings().when == FIREWALL_WHEN_BEFORE_CONNECTION)
1425 {
1426 if (firewallController_->firewallActualState())
1427 {
1428 qCDebug(LOG_BASIC) << "Automatic disable firewall after connection";
1429 firewallController_->firewallOff();
1430 emit firewallStateChanged(false);
1431 }
1432 }
1433 }
1434
1435 // For Windows we should to set the custom dns for the adapter explicitly except WireGuard protocol
1436#ifdef Q_OS_WIN
1437 if ((connectionManager_->connectedDnsInfo().type == CONNECTED_DNS_TYPE_CUSTOM || connectionManager_->connectedDnsInfo().type == CONNECTED_DNS_TYPE_CONTROLD)
1438 && connectionManager_->currentProtocol() != types::Protocol::WIREGUARD)
1439 {
1440 WS_ASSERT(connectionManager_->getVpnAdapterInfo().dnsServers().count() == 1);
1441 if (!helper_->setCustomDnsWhileConnected( connectionManager_->getVpnAdapterInfo().ifIndex(),
1442 QString::fromStdString(connectionManager_->getVpnAdapterInfo().dnsServers().first().toString())))
1443 {
1444 qCCritical(LOG_CONNECTED_DNS) << "Failed to set Custom 'while connected' DNS";
1445 }
1446 }

Callers

nothing calls this directly

Calls 15

adapterNameMethod · 0.80
isWireGuardProtocolMethod · 0.80
getLastConnectedIpMethod · 0.80
connectedDnsInfoMethod · 0.80
dnsServersMethod · 0.80
ifIndexMethod · 0.80
toStringMethod · 0.80
getDefaultAdapterInfoMethod · 0.80

Tested by

no test coverage detected