OpenVpn runtime error codes handling
This commit is contained in:
parent
f45fb442de
commit
861c71e3a8
11 changed files with 59 additions and 26 deletions
|
@ -119,7 +119,7 @@ ErrorCode OpenVpnProtocol::start()
|
|||
m_openVpnStateSigTermHandlerTimer.stop();
|
||||
stop();
|
||||
|
||||
if (communicator() && !communicator()->connected()) {
|
||||
if (communicator() && !communicator()->isConnected()) {
|
||||
setLastError(ErrorCode::AmneziaServiceConnectionFailed);
|
||||
return lastError();
|
||||
}
|
||||
|
@ -213,6 +213,16 @@ void OpenVpnProtocol::onReadyReadDataFromManagementServer()
|
|||
}
|
||||
}
|
||||
|
||||
if (line.contains("FATAL")) {
|
||||
if (line.contains("tap-windows6 adapters on this system are currently in use or disabled")) {
|
||||
emit protocolError(ErrorCode::OpenVpnAdaptersInUseError);
|
||||
}
|
||||
else {
|
||||
emit protocolError(ErrorCode::OpenVpnUnknownError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QByteArray data(line.toStdString().c_str());
|
||||
if (data.contains(">BYTECOUNT:")) {
|
||||
int beg = data.lastIndexOf(">BYTECOUNT:");
|
||||
|
|
|
@ -93,14 +93,14 @@ void VpnProtocol::setConnectionState(VpnProtocol::ConnectionState state)
|
|||
QString VpnProtocol::textConnectionState(ConnectionState connectionState)
|
||||
{
|
||||
switch (connectionState) {
|
||||
case ConnectionState::Unknown: return "Unknown";
|
||||
case ConnectionState::Disconnected: return "Disconnected";
|
||||
case ConnectionState::Preparing: return "Preparing";
|
||||
case ConnectionState::Connecting: return "Connecting";
|
||||
case ConnectionState::Connected: return "Connected";
|
||||
case ConnectionState::Disconnecting: return "Disconnecting";
|
||||
case ConnectionState::TunnelReconnecting: return "TunnelReconnecting";
|
||||
case ConnectionState::Error: return "Error";
|
||||
case ConnectionState::Unknown: return tr("Unknown");
|
||||
case ConnectionState::Disconnected: return tr("Disconnected");
|
||||
case ConnectionState::Preparing: return tr("Preparing");
|
||||
case ConnectionState::Connecting: return tr("Connecting");
|
||||
case ConnectionState::Connected: return tr("Connected");
|
||||
case ConnectionState::Disconnecting: return tr("Disconnecting");
|
||||
case ConnectionState::TunnelReconnecting: return tr("TunnelReconnecting");
|
||||
case ConnectionState::Error: return tr("Error");
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
@ -113,12 +113,12 @@ QString VpnProtocol::textConnectionState() const
|
|||
return textConnectionState(m_connectionState);
|
||||
}
|
||||
|
||||
bool VpnProtocol::connected() const
|
||||
bool VpnProtocol::onConnected() const
|
||||
{
|
||||
return m_connectionState == ConnectionState::Connected;
|
||||
}
|
||||
|
||||
bool VpnProtocol::disconnected() const
|
||||
bool VpnProtocol::onDisconnected() const
|
||||
{
|
||||
return m_connectionState == ConnectionState::Disconnected;
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ public:
|
|||
static void initializeCommunicator(QObject* parent = nullptr);
|
||||
|
||||
|
||||
virtual bool connected() const;
|
||||
virtual bool disconnected() const;
|
||||
virtual bool onConnected() const;
|
||||
virtual bool onDisconnected() const;
|
||||
virtual ErrorCode start() = 0;
|
||||
virtual void stop() = 0;
|
||||
|
||||
|
@ -39,6 +39,7 @@ signals:
|
|||
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||
void connectionStateChanged(VpnProtocol::ConnectionState state);
|
||||
void timeoutTimerEvent();
|
||||
void protocolError(amnezia::ErrorCode e);
|
||||
|
||||
protected slots:
|
||||
virtual void onTimeout();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue