[WIP] protocol switching and relaunch crash issues (possibly) fixed
This commit is contained in:
parent
b6bab0c723
commit
090e50e936
1 changed files with 27 additions and 17 deletions
|
|
@ -82,20 +82,28 @@ ErrorCode IOSVpnProtocol::start()
|
||||||
switch (m_protocol) {
|
switch (m_protocol) {
|
||||||
case amnezia::Proto::OpenVpn:
|
case amnezia::Proto::OpenVpn:
|
||||||
if (currentProto == amnezia::Proto::WireGuard) {
|
if (currentProto == amnezia::Proto::WireGuard) {
|
||||||
setupOpenVPNProtocol(result);
|
if (m_controller) {
|
||||||
|
stop();
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
launchOpenVPNTunnel(result);
|
launchOpenVPNTunnel(result);
|
||||||
currentProto = amnezia::Proto::OpenVpn;
|
currentProto = amnezia::Proto::OpenVpn;
|
||||||
return NoError;
|
return NoError;
|
||||||
}
|
}
|
||||||
|
initialize();
|
||||||
launchOpenVPNTunnel(result);
|
launchOpenVPNTunnel(result);
|
||||||
break;
|
break;
|
||||||
case amnezia::Proto::WireGuard:
|
case amnezia::Proto::WireGuard:
|
||||||
if (currentProto == amnezia::Proto::OpenVpn) {
|
if (currentProto == amnezia::Proto::OpenVpn) {
|
||||||
setupWireguardProtocol(result);
|
if (m_controller) {
|
||||||
|
stop();
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
launchWireguardTunnel(result);
|
launchWireguardTunnel(result);
|
||||||
currentProto = amnezia::Proto::WireGuard;
|
currentProto = amnezia::Proto::WireGuard;
|
||||||
return NoError;
|
return NoError;
|
||||||
}
|
}
|
||||||
|
initialize();
|
||||||
launchWireguardTunnel(result);
|
launchWireguardTunnel(result);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -110,14 +118,20 @@ void IOSVpnProtocol::stop()
|
||||||
if (!m_controller) {
|
if (!m_controller) {
|
||||||
qDebug() << "Not correctly initialized";
|
qDebug() << "Not correctly initialized";
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
emit connectionStateChanged(Disconnected);
|
// emit connectionStateChanged(Disconnected);
|
||||||
});
|
// });
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[m_controller disconnect];
|
[m_controller disconnect];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
emit connectionStateChanged(Disconnected);
|
||||||
|
});
|
||||||
|
|
||||||
|
[m_controller dealloc];
|
||||||
|
m_controller = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOSVpnProtocol::resume_start()
|
void IOSVpnProtocol::resume_start()
|
||||||
|
|
@ -302,9 +316,9 @@ void IOSVpnProtocol::setupWireguardProtocol(const QtJson::JsonObject &result)
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
emit connectionStateChanged(Disconnected);
|
// emit connectionStateChanged(Disconnected);
|
||||||
});
|
// });
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -344,7 +358,7 @@ void IOSVpnProtocol::setupOpenVPNProtocol(const QtJson::JsonObject &result)
|
||||||
}
|
}
|
||||||
case ConnectionStateDisconnected:
|
case ConnectionStateDisconnected:
|
||||||
// Just in case we are connecting, let's call disconnect.
|
// Just in case we are connecting, let's call disconnect.
|
||||||
[m_controller disconnect];
|
// [m_controller disconnect];
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
emit connectionStateChanged(VpnConnectionState::Disconnected);
|
emit connectionStateChanged(VpnConnectionState::Disconnected);
|
||||||
});
|
});
|
||||||
|
|
@ -363,9 +377,9 @@ void IOSVpnProtocol::setupOpenVPNProtocol(const QtJson::JsonObject &result)
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
emit connectionStateChanged(Disconnected);
|
// emit connectionStateChanged(Disconnected);
|
||||||
});
|
// });
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -439,7 +453,3 @@ void IOSVpnProtocol::launchOpenVPNTunnel(const QtJson::JsonObject &result)
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue