2017-08-28 10:35:15 +00:00
|
|
|
#ifndef FIREWALLCONF_H
|
|
|
|
#define FIREWALLCONF_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QQmlListProperty>
|
2017-08-30 07:03:28 +00:00
|
|
|
#include <QVariant>
|
2017-08-28 10:35:15 +00:00
|
|
|
|
2017-12-06 02:51:40 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(AddressGroup)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(AppGroup)
|
2017-08-28 10:35:15 +00:00
|
|
|
|
2017-12-11 06:05:49 +00:00
|
|
|
#define DEFAULT_APP_GROUP_BITS 0xFFFF
|
2018-01-12 11:21:38 +00:00
|
|
|
#define DEFAULT_MONTH_START 1
|
2017-12-11 06:05:49 +00:00
|
|
|
#define DEFAULT_TRAF_HOUR_KEEP_DAYS 90 // ~3 months
|
2017-12-14 08:44:10 +00:00
|
|
|
#define DEFAULT_TRAF_DAY_KEEP_DAYS 365 // ~1 year
|
2017-12-11 06:05:49 +00:00
|
|
|
#define DEFAULT_TRAF_MONTH_KEEP_MONTHS 360 // ~3 years
|
|
|
|
|
2017-08-28 10:35:15 +00:00
|
|
|
class FirewallConf : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2017-10-27 11:59:09 +00:00
|
|
|
Q_PROPERTY(bool provBoot READ provBoot WRITE setProvBoot NOTIFY provBootChanged)
|
2017-09-01 10:05:30 +00:00
|
|
|
Q_PROPERTY(bool filterEnabled READ filterEnabled WRITE setFilterEnabled NOTIFY filterEnabledChanged)
|
2017-12-23 06:15:36 +00:00
|
|
|
Q_PROPERTY(bool stopTraffic READ stopTraffic WRITE setStopTraffic NOTIFY stopTrafficChanged)
|
2018-01-12 08:52:09 +00:00
|
|
|
Q_PROPERTY(bool stopInetTraffic READ stopInetTraffic WRITE setStopInetTraffic NOTIFY stopInetTrafficChanged)
|
2017-11-20 14:39:57 +00:00
|
|
|
Q_PROPERTY(bool resolveAddress READ resolveAddress WRITE setResolveAddress NOTIFY resolveAddressChanged)
|
2018-01-11 08:54:38 +00:00
|
|
|
Q_PROPERTY(bool logErrors READ logErrors WRITE setLogErrors NOTIFY logErrorsChanged)
|
2017-11-03 04:18:37 +00:00
|
|
|
Q_PROPERTY(bool logBlocked READ logBlocked WRITE setLogBlocked NOTIFY logBlockedChanged)
|
|
|
|
Q_PROPERTY(bool logStat READ logStat WRITE setLogStat NOTIFY logStatChanged)
|
2017-08-28 10:35:15 +00:00
|
|
|
Q_PROPERTY(bool appBlockAll READ appBlockAll WRITE setAppBlockAll NOTIFY appBlockAllChanged)
|
|
|
|
Q_PROPERTY(bool appAllowAll READ appAllowAll WRITE setAppAllowAll NOTIFY appAllowAllChanged)
|
2018-01-12 11:21:38 +00:00
|
|
|
Q_PROPERTY(int monthStart READ monthStart WRITE setMonthStart NOTIFY monthStartChanged)
|
2017-12-11 06:05:49 +00:00
|
|
|
Q_PROPERTY(int trafHourKeepDays READ trafHourKeepDays WRITE setTrafHourKeepDays NOTIFY trafHourKeepDaysChanged)
|
|
|
|
Q_PROPERTY(int trafDayKeepDays READ trafDayKeepDays WRITE setTrafDayKeepDays NOTIFY trafDayKeepDaysChanged)
|
|
|
|
Q_PROPERTY(int trafMonthKeepMonths READ trafMonthKeepMonths WRITE setTrafMonthKeepMonths NOTIFY trafMonthKeepMonthsChanged)
|
|
|
|
Q_PROPERTY(int trafUnit READ trafUnit WRITE setTrafUnit NOTIFY trafUnitChanged)
|
2018-01-10 09:57:27 +00:00
|
|
|
Q_PROPERTY(bool hasPassword READ hasPassword NOTIFY passwordHashChanged)
|
|
|
|
Q_PROPERTY(QString passwordHash READ passwordHash WRITE setPasswordHash NOTIFY passwordHashChanged)
|
2018-01-20 08:57:22 +00:00
|
|
|
Q_PROPERTY(AddressGroup *inetAddressGroup READ inetAddressGroup NOTIFY addressGroupsChanged)
|
|
|
|
Q_PROPERTY(QQmlListProperty<AddressGroup> addressGroups READ addressGroups NOTIFY addressGroupsChanged)
|
2017-08-28 10:35:15 +00:00
|
|
|
Q_PROPERTY(QQmlListProperty<AppGroup> appGroups READ appGroups NOTIFY appGroupsChanged)
|
|
|
|
Q_CLASSINFO("DefaultProperty", "appGroups")
|
|
|
|
|
|
|
|
public:
|
2017-12-11 06:05:49 +00:00
|
|
|
enum TrafUnit {
|
|
|
|
UnitAdaptive = 0,
|
|
|
|
UnitBytes,
|
|
|
|
UnitKB,
|
|
|
|
UnitMB,
|
|
|
|
UnitGB,
|
|
|
|
UnitTB
|
|
|
|
};
|
|
|
|
Q_ENUM(TrafUnit)
|
|
|
|
|
2017-08-28 10:35:15 +00:00
|
|
|
explicit FirewallConf(QObject *parent = nullptr);
|
|
|
|
|
2017-10-27 11:59:09 +00:00
|
|
|
bool provBoot() const { return m_provBoot; }
|
|
|
|
void setProvBoot(bool provBoot);
|
|
|
|
|
2017-09-01 10:05:30 +00:00
|
|
|
bool filterEnabled() const { return m_filterEnabled; }
|
|
|
|
void setFilterEnabled(bool filterEnabled);
|
2017-08-28 10:35:15 +00:00
|
|
|
|
2017-12-23 06:15:36 +00:00
|
|
|
bool stopTraffic() const { return m_stopTraffic; }
|
|
|
|
void setStopTraffic(bool stopTraffic);
|
|
|
|
|
2018-01-12 08:52:09 +00:00
|
|
|
bool stopInetTraffic() const { return m_stopInetTraffic; }
|
|
|
|
void setStopInetTraffic(bool stopInetTraffic);
|
|
|
|
|
2017-11-20 14:39:57 +00:00
|
|
|
bool resolveAddress() const { return m_resolveAddress; }
|
|
|
|
void setResolveAddress(bool resolveAddress);
|
|
|
|
|
2018-01-11 08:54:38 +00:00
|
|
|
bool logErrors() const { return m_logErrors; }
|
|
|
|
void setLogErrors(bool logErrors);
|
|
|
|
|
2017-11-03 04:18:37 +00:00
|
|
|
bool logBlocked() const { return m_logBlocked; }
|
|
|
|
void setLogBlocked(bool logBlocked);
|
|
|
|
|
|
|
|
bool logStat() const { return m_logStat; }
|
|
|
|
void setLogStat(bool logStat);
|
2017-08-28 10:35:15 +00:00
|
|
|
|
|
|
|
bool appBlockAll() const { return m_appBlockAll; }
|
|
|
|
void setAppBlockAll(bool appBlockAll);
|
|
|
|
|
|
|
|
bool appAllowAll() const { return m_appAllowAll; }
|
|
|
|
void setAppAllowAll(bool appAllowAll);
|
|
|
|
|
2018-01-12 11:21:38 +00:00
|
|
|
int monthStart() const { return m_monthStart; }
|
|
|
|
void setMonthStart(int monthStart);
|
|
|
|
|
2017-12-11 06:05:49 +00:00
|
|
|
int trafHourKeepDays() const { return m_trafHourKeepDays; }
|
|
|
|
void setTrafHourKeepDays(int trafHourKeepDays);
|
|
|
|
|
|
|
|
int trafDayKeepDays() const { return m_trafDayKeepDays; }
|
|
|
|
void setTrafDayKeepDays(int trafDayKeepDays);
|
|
|
|
|
|
|
|
int trafMonthKeepMonths() const { return m_trafMonthKeepMonths; }
|
|
|
|
void setTrafMonthKeepMonths(int trafMonthKeepMonths);
|
|
|
|
|
|
|
|
int trafUnit() const { return m_trafUnit; }
|
|
|
|
void setTrafUnit(int trafUnit);
|
|
|
|
|
2018-01-10 09:57:27 +00:00
|
|
|
bool hasPassword() const { return !m_passwordHash.isEmpty(); }
|
|
|
|
|
|
|
|
QString passwordHash() const { return m_passwordHash; }
|
|
|
|
void setPasswordHash(const QString &passwordHash);
|
|
|
|
|
2017-08-30 16:20:31 +00:00
|
|
|
quint32 appGroupBits() const;
|
|
|
|
void setAppGroupBits(quint32 groupBits);
|
|
|
|
|
2018-01-20 08:57:22 +00:00
|
|
|
AddressGroup *inetAddressGroup() const { return m_addressGroups.at(0); }
|
|
|
|
|
|
|
|
const QList<AddressGroup *> &addressGroupsList() const { return m_addressGroups; }
|
|
|
|
QQmlListProperty<AddressGroup> addressGroups();
|
2017-08-28 10:35:15 +00:00
|
|
|
|
2017-08-29 08:40:23 +00:00
|
|
|
const QList<AppGroup *> &appGroupsList() const { return m_appGroups; }
|
2017-08-28 10:35:15 +00:00
|
|
|
QQmlListProperty<AppGroup> appGroups();
|
|
|
|
|
2017-09-03 03:48:29 +00:00
|
|
|
void copyFlags(const FirewallConf &o);
|
2017-12-14 10:23:40 +00:00
|
|
|
void copyImmediateFlags(const FirewallConf &o);
|
2017-09-03 03:48:29 +00:00
|
|
|
|
2017-08-30 07:03:28 +00:00
|
|
|
QVariant toVariant() const;
|
|
|
|
void fromVariant(const QVariant &v);
|
|
|
|
|
2018-01-09 08:25:51 +00:00
|
|
|
void setupDefault();
|
|
|
|
|
2017-08-28 10:35:15 +00:00
|
|
|
signals:
|
2017-10-27 11:59:09 +00:00
|
|
|
void provBootChanged();
|
2017-09-01 10:05:30 +00:00
|
|
|
void filterEnabledChanged();
|
2017-12-23 06:15:36 +00:00
|
|
|
void stopTrafficChanged();
|
2018-01-12 08:52:09 +00:00
|
|
|
void stopInetTrafficChanged();
|
2017-11-20 14:39:57 +00:00
|
|
|
void resolveAddressChanged();
|
2018-01-11 08:54:38 +00:00
|
|
|
void logErrorsChanged();
|
2017-11-03 04:18:37 +00:00
|
|
|
void logBlockedChanged();
|
|
|
|
void logStatChanged();
|
2017-08-28 10:35:15 +00:00
|
|
|
void appBlockAllChanged();
|
|
|
|
void appAllowAllChanged();
|
2018-01-12 11:21:38 +00:00
|
|
|
void monthStartChanged();
|
2017-12-11 06:05:49 +00:00
|
|
|
void trafHourKeepDaysChanged();
|
|
|
|
void trafDayKeepDaysChanged();
|
|
|
|
void trafMonthKeepMonthsChanged();
|
|
|
|
void trafUnitChanged();
|
2018-01-10 09:57:27 +00:00
|
|
|
void passwordHashChanged();
|
2018-01-20 08:57:22 +00:00
|
|
|
void addressGroupsChanged();
|
2017-08-28 10:35:15 +00:00
|
|
|
void appGroupsChanged();
|
|
|
|
|
|
|
|
public slots:
|
2017-09-02 12:52:39 +00:00
|
|
|
void addAppGroup(AppGroup *appGroup, int to = -1);
|
|
|
|
void addAppGroupByName(const QString &name);
|
|
|
|
void moveAppGroup(int from, int to);
|
|
|
|
void removeAppGroup(int from, int to);
|
2017-08-28 10:35:15 +00:00
|
|
|
|
|
|
|
private:
|
2017-10-27 11:59:09 +00:00
|
|
|
uint m_provBoot : 1;
|
2017-09-01 10:05:30 +00:00
|
|
|
uint m_filterEnabled : 1;
|
2017-12-23 06:15:36 +00:00
|
|
|
uint m_stopTraffic : 1;
|
2018-01-12 08:52:09 +00:00
|
|
|
uint m_stopInetTraffic : 1;
|
2017-08-28 10:35:15 +00:00
|
|
|
|
2017-11-20 14:39:57 +00:00
|
|
|
uint m_resolveAddress : 1;
|
|
|
|
|
2018-01-11 08:54:38 +00:00
|
|
|
uint m_logErrors : 1;
|
2017-11-20 14:39:57 +00:00
|
|
|
uint m_logBlocked : 1;
|
2017-11-03 04:18:37 +00:00
|
|
|
uint m_logStat : 1;
|
2017-09-02 13:48:33 +00:00
|
|
|
|
2017-08-28 10:35:15 +00:00
|
|
|
uint m_appBlockAll : 1;
|
|
|
|
uint m_appAllowAll : 1;
|
|
|
|
|
2018-01-12 11:21:38 +00:00
|
|
|
uint m_monthStart : 5;
|
|
|
|
|
2017-12-11 06:05:49 +00:00
|
|
|
int m_trafHourKeepDays;
|
|
|
|
int m_trafDayKeepDays;
|
|
|
|
int m_trafMonthKeepMonths;
|
|
|
|
|
|
|
|
TrafUnit m_trafUnit;
|
|
|
|
|
2018-01-10 09:57:27 +00:00
|
|
|
QString m_passwordHash;
|
|
|
|
|
2018-01-20 08:57:22 +00:00
|
|
|
QList<AddressGroup *> m_addressGroups;
|
2017-08-28 10:35:15 +00:00
|
|
|
QList<AppGroup *> m_appGroups;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FIREWALLCONF_H
|