added client management panel
- added classes for displaying the client management panel - added class for displaying the client info - added page to display a list of clients - added page to display OpenVpn client information - added diagram with OpenVpn certificate revocation process
This commit is contained in:
parent
3f257af7a9
commit
a42beb86c0
19 changed files with 771 additions and 102 deletions
|
@ -796,6 +796,59 @@ SshConnection *ServerController::connectToHost(const SshConnectionParameters &ss
|
|||
return client;
|
||||
}
|
||||
|
||||
ErrorCode ServerController::getClientsList(const ServerCredentials &credentials, DockerContainer container, Proto mainProtocol, QJsonObject &clietns)
|
||||
{
|
||||
QString stdOut;
|
||||
auto cbReadStdOut = [&](const QString &data, QSharedPointer<QSsh::SshRemoteProcess> proc) {
|
||||
stdOut += data + "\n";
|
||||
};
|
||||
|
||||
ErrorCode error = ErrorCode::NoError;
|
||||
if (mainProtocol == Proto::OpenVpn) {
|
||||
error = runScript(credentials,
|
||||
replaceVars(QString("sudo docker exec -i $CONTAINER_NAME bash -c 'ls /opt/amnezia/openvpn/pki/issued'"),
|
||||
genVarsForScript(credentials, container)), cbReadStdOut);
|
||||
// TODO error processing
|
||||
if (!stdOut.isEmpty()) {
|
||||
QStringList clietnsNames = stdOut.split("\n", Qt::SkipEmptyParts);
|
||||
clietnsNames.removeAll("AmneziaReq.crt");
|
||||
|
||||
QByteArray clientsTableString = getTextFileFromContainer(container, credentials, "opt/amnezia/openvpn/clientsTable");
|
||||
QJsonObject clientsTable = QJsonDocument::fromJson(clientsTableString).object();
|
||||
for (auto &clietnId : clietnsNames) {
|
||||
clietnId.replace(".crt", "");
|
||||
if (!clientsTable.contains(clietnId)) {
|
||||
stdOut.clear();
|
||||
error = runScript(credentials,
|
||||
replaceVars(QString("sudo docker exec -i $CONTAINER_NAME bash -c 'cat /opt/amnezia/openvpn/pki/issued/%1.crt'").arg(clietnId),
|
||||
genVarsForScript(credentials, container)), cbReadStdOut);
|
||||
// TODO error processing
|
||||
QJsonObject client;
|
||||
client["name"] = "";
|
||||
client["certificate"] = stdOut;
|
||||
clientsTable[clietnId] = client;
|
||||
}
|
||||
}
|
||||
QByteArray newClientsTableString = QJsonDocument(clientsTable).toJson();
|
||||
if (clientsTableString != newClientsTableString) {
|
||||
error = uploadTextFileToContainer(container, credentials, newClientsTableString, "opt/amnezia/openvpn/clientsTable");
|
||||
}
|
||||
// TODO error processing
|
||||
clietns = clientsTable;
|
||||
}
|
||||
} else if (mainProtocol == Proto::WireGuard) {
|
||||
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
ErrorCode ServerController::setClientsList(const ServerCredentials &credentials, DockerContainer container, Proto mainProtocol, QJsonObject &clietns)
|
||||
{
|
||||
auto error = uploadTextFileToContainer(container, credentials, QJsonDocument(clietns).toJson(), "opt/amnezia/openvpn/clientsTable");
|
||||
return error;
|
||||
}
|
||||
|
||||
void ServerController::disconnectFromHost(const ServerCredentials &credentials)
|
||||
{
|
||||
SshConnection *client = acquireConnection(sshParams(credentials));
|
||||
|
|
|
@ -73,6 +73,9 @@ public:
|
|||
QString checkSshConnection(const ServerCredentials &credentials, ErrorCode *errorCode = nullptr);
|
||||
QSsh::SshConnection *connectToHost(const QSsh::SshConnectionParameters &sshParams);
|
||||
|
||||
ErrorCode getClientsList(const ServerCredentials &credentials, DockerContainer container, Proto mainProtocol, QJsonObject &clietns);
|
||||
ErrorCode setClientsList(const ServerCredentials &credentials, DockerContainer container, Proto mainProtocol, QJsonObject &clietns);
|
||||
|
||||
private:
|
||||
|
||||
ErrorCode installDockerWorker(const ServerCredentials &credentials, DockerContainer container);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue