2023-07-13 11:29:26 +09:00
|
|
|
#ifndef WIREGUARDCONFIGMODEL_H
|
|
|
|
|
#define WIREGUARDCONFIGMODEL_H
|
|
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
#include "core/utils/containerEnum.h"
|
|
|
|
|
#include "core/utils/containers/containerUtils.h"
|
|
|
|
|
#include "core/utils/protocolEnum.h"
|
|
|
|
|
#include "core/models/protocols/wireGuardProtocolConfig.h"
|
2024-03-18 12:41:53 +02:00
|
|
|
|
2023-07-13 11:29:26 +09:00
|
|
|
class WireGuardConfigModel : public QAbstractListModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum Roles {
|
2025-01-02 08:07:12 +01:00
|
|
|
SubnetAddressRole = Qt::UserRole + 1,
|
|
|
|
|
PortRole,
|
2024-09-13 12:38:48 +04:00
|
|
|
ClientMtuRole
|
2023-07-13 11:29:26 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
explicit WireGuardConfigModel(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
|
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
|
|
|
|
|
|
public slots:
|
2026-04-30 14:53:03 +08:00
|
|
|
void updateModel(amnezia::DockerContainer container, const amnezia::WireGuardProtocolConfig &protocolConfig);
|
|
|
|
|
amnezia::WireGuardProtocolConfig getProtocolConfig();
|
2023-07-13 11:29:26 +09:00
|
|
|
|
2024-09-13 12:38:48 +04:00
|
|
|
bool isServerSettingsEqual();
|
|
|
|
|
|
2023-07-13 11:29:26 +09:00
|
|
|
protected:
|
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
|
|
|
|
|
|
private:
|
2026-04-30 14:53:03 +08:00
|
|
|
amnezia::DockerContainer m_container;
|
|
|
|
|
amnezia::WireGuardProtocolConfig m_protocolConfig;
|
|
|
|
|
amnezia::WireGuardProtocolConfig m_originalProtocolConfig;
|
|
|
|
|
|
|
|
|
|
void applyDefaultsToServerConfig(amnezia::WireGuardServerConfig& config);
|
|
|
|
|
void applyDefaultsToClientConfig(amnezia::WireGuardClientConfig& config);
|
2023-07-13 11:29:26 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // WIREGUARDCONFIGMODEL_H
|