Merge pull request #523 from amnezia-vpn/fix/ios-log
Fix/iOS log (Part 1)
This commit is contained in:
commit
73cfab166f
3 changed files with 62 additions and 9 deletions
|
|
@ -29,7 +29,7 @@ void debugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip annoying messages from Qt
|
// Skip annoying messages from Qt
|
||||||
if (msg.startsWith("Unknown property") || msg.startsWith("Could not create pixmap") || msg.startsWith("Populating font")) {
|
if (msg.startsWith("Unknown property") || msg.startsWith("Could not create pixmap") || msg.startsWith("Populating font") || msg.startsWith("stale focus object")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -249,8 +249,51 @@ void IosController::vpnStatusDidChange(void *pNotification)
|
||||||
NETunnelProviderSession *session = (NETunnelProviderSession *)pNotification;
|
NETunnelProviderSession *session = (NETunnelProviderSession *)pNotification;
|
||||||
|
|
||||||
if (session /* && session == TunnelManager.session */ ) {
|
if (session /* && session == TunnelManager.session */ ) {
|
||||||
qDebug() << "IosController::vpnStatusDidChange" << iosStatusToState(session.status) << session;
|
qDebug() << "IosController::vpnStatusDidChange" << iosStatusToState(session.status) << session;
|
||||||
emit connectionStateChanged(iosStatusToState(session.status));
|
|
||||||
|
if (session.status == NEVPNStatusDisconnected) {
|
||||||
|
if (@available(iOS 16.0, *)) {
|
||||||
|
[session fetchLastDisconnectErrorWithCompletionHandler:^(NSError * _Nullable error) {
|
||||||
|
if (error != nil) {
|
||||||
|
qDebug() << "Disconnect error" << error.domain << error.localizedDescription;
|
||||||
|
|
||||||
|
if ([error.domain isEqualToString:NEVPNConnectionErrorDomain]) {
|
||||||
|
switch (error.code) {
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *underlyingError = error.userInfo[@"NSUnderlyingError"];
|
||||||
|
if (underlyingError != nil) {
|
||||||
|
qDebug() << "Disconnect underlying error" << underlyingError.domain << underlyingError.localizedDescription;
|
||||||
|
|
||||||
|
if ([underlyingError.domain isEqualToString:@"NEAgentErrorDomain"]) {
|
||||||
|
switch (underlyingError.code) {
|
||||||
|
case 1:
|
||||||
|
qDebug() << "Disconnect underlying error" << "General. Use sysdiagnose.";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
qDebug() << "Disconnect underlying error" << "Plug-in unavailable. Use sysdiagnose.";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qDebug() << "Disconnect underlying error" << "Unknown code. Use sysdiagnose.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Disconnect error is absent";
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
qDebug() << "Disconnect error is unavailable on iOS < 16.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit connectionStateChanged(iosStatusToState(session.status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,6 +395,15 @@ bool IosController::startWireGuard(const QString &config)
|
||||||
|
|
||||||
void IosController::startTunnel()
|
void IosController::startTunnel()
|
||||||
{
|
{
|
||||||
|
NSString *protocolName = @"Unknown";
|
||||||
|
|
||||||
|
NETunnelProviderProtocol *tunnelProtocol = (NETunnelProviderProtocol *)m_currentTunnel.protocolConfiguration;
|
||||||
|
if (tunnelProtocol.providerConfiguration[@"wireguard"] != nil) {
|
||||||
|
protocolName = @"WireGuard";
|
||||||
|
} else if (tunnelProtocol.providerConfiguration[@"ovpn"] != nil) {
|
||||||
|
protocolName = @"OpenVPN";
|
||||||
|
}
|
||||||
|
|
||||||
m_rxBytes = 0;
|
m_rxBytes = 0;
|
||||||
m_txBytes = 0;
|
m_txBytes = 0;
|
||||||
|
|
||||||
|
|
@ -373,7 +425,7 @@ void IosController::startTunnel()
|
||||||
|
|
||||||
[m_currentTunnel loadFromPreferencesWithCompletionHandler:^(NSError *loadError) {
|
[m_currentTunnel loadFromPreferencesWithCompletionHandler:^(NSError *loadError) {
|
||||||
if (loadError) {
|
if (loadError) {
|
||||||
qDebug() << "IosController::startOpenVPN : Connect OpenVPN Tunnel Load Error" << loadError.localizedDescription.UTF8String;
|
qDebug().nospace() << "IosController::start" << protocolName << ": Connect " << protocolName << " Tunnel Load Error" << loadError.localizedDescription.UTF8String;
|
||||||
emit connectionStateChanged(Vpn::ConnectionState::Error);
|
emit connectionStateChanged(Vpn::ConnectionState::Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -401,11 +453,11 @@ void IosController::startTunnel()
|
||||||
BOOL started = [m_currentTunnel.connection startVPNTunnelWithOptions:nil andReturnError:&startError];
|
BOOL started = [m_currentTunnel.connection startVPNTunnelWithOptions:nil andReturnError:&startError];
|
||||||
|
|
||||||
if (!started || startError) {
|
if (!started || startError) {
|
||||||
qDebug() << "IosController::startOpenVPN : Connect OpenVPN Tunnel Start Error"
|
qDebug().nospace() << "IosController::start" << protocolName << " : Connect " << protocolName << " Tunnel Start Error"
|
||||||
<< (startError ? startError.localizedDescription.UTF8String : "");
|
<< (startError ? startError.localizedDescription.UTF8String : "");
|
||||||
emit connectionStateChanged(Vpn::ConnectionState::Error);
|
emit connectionStateChanged(Vpn::ConnectionState::Error);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "IosController::startOpenVPN : Starting the tunnel succeeded";
|
qDebug().nospace() << "IosController::start" << protocolName << " : Starting the tunnel succeeded";
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,8 @@ PageType {
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Layout.alignment: Qt.AlignBaseline
|
Layout.alignment: Qt.AlignBaseline
|
||||||
Layout.preferredWidth: root.width / 3
|
Layout.preferredWidth: Qt.platform.os === "ios"? 0 : root.width / 3
|
||||||
|
visible: Qt.platform.os !== "ios"
|
||||||
|
|
||||||
ImageButtonType {
|
ImageButtonType {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
@ -90,7 +91,7 @@ PageType {
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Layout.alignment: Qt.AlignBaseline
|
Layout.alignment: Qt.AlignBaseline
|
||||||
Layout.preferredWidth: root.width / 3
|
Layout.preferredWidth: root.width / ( Qt.platform.os === "ios" ? 2 : 3 )
|
||||||
|
|
||||||
ImageButtonType {
|
ImageButtonType {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
@ -131,7 +132,7 @@ PageType {
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Layout.alignment: Qt.AlignBaseline
|
Layout.alignment: Qt.AlignBaseline
|
||||||
Layout.preferredWidth: root.width / 3
|
Layout.preferredWidth: root.width / ( Qt.platform.os === "ios" ? 2 : 3 )
|
||||||
|
|
||||||
ImageButtonType {
|
ImageButtonType {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue