-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from amnezia-vpn/ss/refactoring
Refactoring
- Loading branch information
Showing
21 changed files
with
559 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef DEFS_H | ||
#define DEFS_H | ||
|
||
#include <QObject> | ||
|
||
namespace amnezia { | ||
|
||
enum class Protocol { | ||
Any, | ||
OpenVpn, | ||
ShadowSocks, | ||
WireGuard | ||
}; | ||
|
||
struct ServerCredentials | ||
{ | ||
QString hostName; | ||
QString userName; | ||
QString password; | ||
int port = 22; | ||
}; | ||
|
||
enum ErrorCode | ||
{ | ||
// General error codes | ||
NoError = 0, | ||
UnknownError, | ||
InternalError, | ||
NotImplementedError, | ||
|
||
// Server errorz | ||
ServerCheckFailed, | ||
|
||
// Ssh connection errors | ||
SshSocketError, SshTimeoutError, SshProtocolError, | ||
SshHostKeyError, SshKeyFileError, SshAuthenticationError, | ||
SshClosedByServerError, SshInternalError, | ||
|
||
// Ssh remote process errors | ||
SshRemoteProcessCreationError, | ||
FailedToStartRemoteProcessError, RemoteProcessCrashError, | ||
|
||
// Local errors | ||
FailedToSaveConfigData, | ||
OpenVpnConfigMissing, | ||
OpenVpnManagementServerError, | ||
|
||
// Distro errors | ||
AmneziaServiceConnectionFailed, | ||
OpenVpnExecutableMissing, | ||
EasyRsaExecutableMissing | ||
}; | ||
|
||
} // namespace amnezia | ||
|
||
#endif // DEFS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef ERRORSTRINGS_H | ||
#define ERRORSTRINGS_H | ||
|
||
#include "defs.h" | ||
using namespace amnezia; | ||
|
||
QString errorString(ErrorCode code){ | ||
switch (code) { | ||
|
||
// General error codes | ||
case(NoError): return QObject::tr("No error"); | ||
case(UnknownError): return QObject::tr("Unknown Error"); | ||
case(NotImplementedError): return QObject::tr("Function not implemented"); | ||
case(ServerCheckFailed): return QObject::tr("Server check failed"); | ||
|
||
// Ssh connection errors | ||
case(SshSocketError): return QObject::tr("Ssh connection error"); | ||
case(SshTimeoutError): return QObject::tr("Ssh connection timeout"); | ||
case(SshProtocolError): return QObject::tr("Ssh protocol error"); | ||
case(SshHostKeyError): return QObject::tr("Ssh server ket check failed"); | ||
case(SshKeyFileError): return QObject::tr("Ssh key file error"); | ||
case(SshAuthenticationError): return QObject::tr("Ssh authentication error"); | ||
case(SshClosedByServerError): return QObject::tr("Ssh session closed"); | ||
case(SshInternalError): return QObject::tr("Ssh internal error"); | ||
|
||
// Ssh remote process errors | ||
case(SshRemoteProcessCreationError): return QObject::tr("Failed to create remote process on server"); | ||
case(FailedToStartRemoteProcessError): return QObject::tr("Failed to start remote process on server"); | ||
case(RemoteProcessCrashError): return QObject::tr("Remote process on server crashed"); | ||
|
||
// Local errors | ||
case (FailedToSaveConfigData): return QObject::tr("Failed to save config to disk"); | ||
case (OpenVpnConfigMissing): return QObject::tr("OpenVPN config missing"); | ||
case (OpenVpnManagementServerError): return QObject::tr("OpenVpn management server error"); | ||
|
||
case (OpenVpnExecutableMissing): return QObject::tr("OpenVPN executable missing"); | ||
case (EasyRsaExecutableMissing): return QObject::tr("EasyRsa executable missing"); | ||
case (AmneziaServiceConnectionFailed): return QObject::tr("Amnezia helper service error"); | ||
|
||
case(InternalError): | ||
default: | ||
return QObject::tr("Internal error"); | ||
} | ||
} | ||
|
||
|
||
#endif // ERRORSTRINGS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.