UI: ApplicationsPage: Add hour period to enabled state.

This commit is contained in:
Nodir Temirkhodjaev 2018-12-07 22:07:48 +05:00
parent a110498d32
commit c606225c35
19 changed files with 308 additions and 41 deletions

View File

@ -1,6 +1,7 @@
/* Fort Firewall Driver Configuration */
#include "fortconf.h"
#include "util.h"
#ifndef FORT_DRIVER
@ -104,10 +105,10 @@ static int
fort_conf_app_index (const PFORT_CONF conf,
UINT32 path_len, const char *path)
{
const UINT32 count = conf->apps_n;
const char *data;
const UINT32 *app_offsets;
const char *apps;
const UINT32 count = conf->apps_n;
int low, high;
if (count == 0)
@ -168,10 +169,52 @@ fort_conf_app_blocked (const PFORT_CONF conf, int app_index)
: (app_blocked && !app_allowed));
}
static void
fort_conf_app_perms_mask_init (PFORT_CONF conf)
static UINT16
fort_conf_app_period_bits (const PFORT_CONF conf, int hour, int *periods_n)
{
const char *data;
const CHAR *app_periods;
UINT16 group_bits, period_bits;
UINT8 count = conf->app_periods_n;
int n, i;
if (count == 0)
return 0;
data = conf->data;
app_periods = (const CHAR *) (data + conf->app_periods_off);
group_bits = (UINT16) conf->flags.group_bits;
period_bits = group_bits;
n = 0;
for (i = 0; i < FORT_CONF_GROUP_MAX; ++i) {
const UINT16 bit = (1 << i);
const int periodFrom = *app_periods++;
const int periodTo = *app_periods++;
if ((group_bits & bit) != 0
&& (periodFrom != 0 || periodTo != 0)) {
if (!is_hour_between(hour, periodFrom, periodTo)) {
period_bits ^= bit;
}
++n;
if (--count == 0)
break;
}
}
if (periods_n != NULL) {
*periods_n = n;
}
return period_bits;
}
static void
fort_conf_app_perms_mask_init (PFORT_CONF conf, UINT32 group_bits)
{
const UINT32 group_bits = conf->flags.group_bits;
UINT32 perms_mask =
(group_bits & 0x0001) | ((group_bits & 0x0002) << 1)
| ((group_bits & 0x0004) << 2) | ((group_bits & 0x0008) << 3)

View File

@ -19,7 +19,7 @@ typedef struct fort_conf_flags {
UINT32 app_allow_all : 1;
UINT32 log_blocked : 1;
UINT32 log_stat : 1;
UINT32 _reserved_ : 9;
UINT32 group_bits : 16;
} FORT_CONF_FLAGS, *PFORT_CONF_FLAGS;
@ -43,6 +43,7 @@ typedef struct fort_conf {
FORT_CONF_FLAGS flags;
UINT16 apps_n;
UCHAR app_periods_n;
UINT32 app_perms_block_mask;
UINT32 app_perms_allow_mask;
@ -51,6 +52,7 @@ typedef struct fort_conf {
UINT32 app_groups_off;
UINT32 app_perms_off;
UINT32 app_periods_off;
UINT32 apps_off;
char data[4];

8
src/common/util.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef UTIL_H
#define UTIL_H
#define is_hour_between(hour,from,to) \
(from <= to ? (hour >= from && hour < to) \
: (hour >= from || hour < to))
#endif UTIL_H

View File

@ -7,6 +7,6 @@
#define APP_UPDATES_URL "https://github.com/tnodir/fort/releases"
#define APP_UPDATES_API_URL "https://api.github.com/repos/tnodir/fort/releases/latest"
#define DRIVER_VERSION 7
#define DRIVER_VERSION 8
#endif // VERSION_H

View File

@ -50,7 +50,8 @@ typedef struct fort_device {
FORT_BUFFER buffer;
FORT_STAT stat;
FORT_DEFER defer;
FORT_TIMER timer;
FORT_TIMER log_timer;
FORT_TIMER app_timer;
} FORT_DEVICE, *PFORT_DEVICE;
static PFORT_DEVICE g_device = NULL;
@ -160,7 +161,7 @@ fort_conf_ref_flags_set (const PFORT_CONF_FLAGS conf_flags)
old_conf_flags = conf->flags;
conf->flags = *conf_flags;
fort_conf_app_perms_mask_init(conf);
fort_conf_app_perms_mask_init(conf, conf->flags.group_bits);
g_device->prov_boot = conf_flags->prov_boot;
@ -177,6 +178,46 @@ fort_conf_ref_flags_set (const PFORT_CONF_FLAGS conf_flags)
return old_conf_flags;
}
static BOOL
fort_conf_period_update (void)
{
PFORT_CONF_REF conf_ref;
int hour;
BOOL res = FALSE;
/* Get current hour */
{
TIME_FIELDS tf;
LARGE_INTEGER system_time, local_time;
KeQuerySystemTime(&system_time);
ExSystemTimeToLocalTime(&system_time, &local_time);
RtlTimeToTimeFields(&local_time, &tf);
hour = (tf.Hour + (tf.Minute > 58 ? 1 : 0)) % 24;
}
conf_ref = fort_conf_ref_take();
if (conf_ref != NULL) {
PFORT_CONF conf = &conf_ref->conf;
if (conf->app_periods_n != 0) {
int periods_n = 0;
const UINT16 period_bits =
fort_conf_app_period_bits(conf, hour, &periods_n);
fort_conf_app_perms_mask_init(conf, period_bits);
res = (periods_n != 0);
}
fort_conf_ref_put(conf_ref);
}
return res;
}
static void
fort_callout_classify_block (FWPS_CLASSIFY_OUT0 *classifyOut)
{
@ -682,7 +723,8 @@ fort_callout_force_reauth (PDEVICE_OBJECT device,
UNUSED(device);
fort_timer_update(&g_device->timer, FALSE);
fort_timer_update(&g_device->log_timer, FALSE);
fort_timer_update(&g_device->app_timer, FALSE);
if (old_conf_flags.log_stat != conf_flags.log_stat) {
fort_stat_update(stat, conf_flags.log_stat);
@ -724,9 +766,13 @@ fort_callout_force_reauth (PDEVICE_OBJECT device,
if ((status = fort_prov_reauth(engine)))
goto cleanup;
fort_timer_update(&g_device->timer,
fort_timer_update(&g_device->log_timer,
(conf_flags.log_blocked || conf_flags.log_stat));
if (fort_conf_period_update()) {
fort_timer_update(&g_device->app_timer, TRUE);
}
cleanup:
if (NT_SUCCESS(status)) {
status = fort_prov_trans_commit(engine);
@ -805,6 +851,12 @@ fort_callout_timer (void)
fort_callout_defer_flush(TRUE);
}
static void
fort_app_period_timer (void)
{
fort_conf_period_update();
}
static NTSTATUS
fort_device_create (PDEVICE_OBJECT device, PIRP irp)
{
@ -1022,7 +1074,8 @@ fort_driver_unload (PDRIVER_OBJECT driver)
if (g_device != NULL) {
fort_callout_defer_flush(FALSE);
fort_timer_close(&g_device->timer);
fort_timer_close(&g_device->app_timer);
fort_timer_close(&g_device->log_timer);
fort_defer_close(&g_device->defer);
fort_stat_close(&g_device->stat);
fort_buffer_close(&g_device->buffer);
@ -1102,7 +1155,8 @@ DriverEntry (PDRIVER_OBJECT driver, PUNICODE_STRING reg_path)
fort_buffer_open(&g_device->buffer);
fort_stat_open(&g_device->stat);
fort_defer_open(&g_device->defer);
fort_timer_open(&g_device->timer, &fort_callout_timer);
fort_timer_open(&g_device->log_timer, 500, &fort_callout_timer);
fort_timer_open(&g_device->app_timer, 60000, &fort_app_period_timer);
KeInitializeSpinLock(&g_device->conf_lock);

View File

@ -4,6 +4,7 @@ typedef void (*FORT_TIMER_FUNC) (void);
typedef struct fort_timer {
UINT32 running : 1;
UINT32 period : 31; /* milliseconds */
FORT_TIMER_FUNC callback;
@ -25,8 +26,9 @@ fort_timer_callback (PKDPC dpc, PFORT_TIMER timer, PVOID arg1, PVOID arg2)
}
static void
fort_timer_open (PFORT_TIMER timer, FORT_TIMER_FUNC callback)
fort_timer_open (PFORT_TIMER timer, int period, FORT_TIMER_FUNC callback)
{
timer->period = period;
timer->callback = callback;
KeInitializeDpc(&timer->dpc, &fort_timer_callback, timer);
@ -54,9 +56,9 @@ fort_timer_update (PFORT_TIMER timer, BOOL run)
timer->running = run;
if (run) {
const LONG period = 500; /* 500ms */
const LONG period = timer->period;
LARGE_INTEGER due;
due.QuadPart = period * -10000; /* 500000us */
due.QuadPart = period * -10000; /* ms -> us */
KeSetTimerEx(&timer->id, due, period, &timer->dpc);
} else {

View File

@ -29,6 +29,9 @@ void Test::confWriteRead()
AppGroup *appGroup1 = new AppGroup();
appGroup1->setName("Base");
appGroup1->setEnabled(true);
appGroup1->setPeriodEnabled(true);
appGroup1->setPeriodFrom(0);
appGroup1->setPeriodTo(12);
appGroup1->setBlockText(
"System"
);
@ -78,6 +81,9 @@ void Test::confWriteRead()
data, FortCommon::confAppIndex(
data, FileUtil::pathToKernelPath("C:\\Program Files\\Test.exe").toLower())));
QCOMPARE(FortCommon::confAppPeriodBits(data, 0), 0x01);
QCOMPARE(FortCommon::confAppPeriodBits(data, 12), 0);
const int firefoxIndex = FortCommon::confAppIndex(
data, FileUtil::pathToKernelPath("C:\\Utils\\Firefox\\Bin\\firefox.exe").toLower());
QVERIFY(FortCommon::confAppBlocked(data, firefoxIndex));

View File

@ -3,6 +3,9 @@
AppGroup::AppGroup(QObject *parent) :
QObject(parent),
m_enabled(true),
m_periodEnabled(false),
m_periodFrom(0),
m_periodTo(0),
m_limitInEnabled(false),
m_limitOutEnabled(false),
m_speedLimitIn(0),
@ -18,6 +21,30 @@ void AppGroup::setEnabled(bool enabled)
}
}
void AppGroup::setPeriodEnabled(bool periodEnabled)
{
if (bool(m_periodEnabled) != periodEnabled) {
m_periodEnabled = periodEnabled;
emit periodEnabledChanged();
}
}
void AppGroup::setPeriodFrom(int periodFrom)
{
if (m_periodFrom != periodFrom) {
m_periodFrom = periodFrom;
emit periodFromChanged();
}
}
void AppGroup::setPeriodTo(int periodTo)
{
if (m_periodTo != periodTo) {
m_periodTo = periodTo;
emit periodToChanged();
}
}
void AppGroup::setLimitInEnabled(bool enabled)
{
if (bool(m_limitInEnabled) != enabled) {
@ -78,6 +105,10 @@ QVariant AppGroup::toVariant() const
{
QVariantMap map;
map["periodEnabled"] = periodEnabled();
map["periodFrom"] = periodFrom();
map["periodTo"] = periodTo();
map["limitInEnabled"] = limitInEnabled();
map["limitOutEnabled"] = limitOutEnabled();
map["speedLimitIn"] = speedLimitIn();
@ -94,6 +125,10 @@ void AppGroup::fromVariant(const QVariant &v)
{
const QVariantMap map = v.toMap();
m_periodEnabled = map["periodEnabled"].toBool();
m_periodFrom = map["periodFrom"].toInt();
m_periodTo = map["periodTo"].toInt();
m_limitInEnabled = map["limitInEnabled"].toBool();
m_limitOutEnabled = map["limitOutEnabled"].toBool();
m_speedLimitIn = map["speedLimitIn"].toUInt();

View File

@ -8,6 +8,9 @@ class AppGroup : public QObject
{
Q_OBJECT
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool periodEnabled READ periodEnabled WRITE setPeriodEnabled NOTIFY periodEnabledChanged)
Q_PROPERTY(int periodFrom READ periodFrom WRITE setPeriodFrom NOTIFY periodFromChanged)
Q_PROPERTY(int periodTo READ periodTo WRITE setPeriodTo NOTIFY periodToChanged)
Q_PROPERTY(bool limitInEnabled READ limitInEnabled WRITE setLimitInEnabled NOTIFY limitInEnabledChanged)
Q_PROPERTY(bool limitOutEnabled READ limitOutEnabled WRITE setLimitOutEnabled NOTIFY limitOutEnabledChanged)
Q_PROPERTY(quint32 speedLimitIn READ speedLimitIn WRITE setSpeedLimitIn NOTIFY speedLimitInChanged)
@ -22,6 +25,15 @@ public:
bool enabled() const { return m_enabled; }
void setEnabled(bool enabled);
bool periodEnabled() const { return m_periodEnabled; }
void setPeriodEnabled(bool periodEnabled);
int periodFrom() const { return m_periodFrom; }
void setPeriodFrom(int periodFrom);
int periodTo() const { return m_periodTo; }
void setPeriodTo(int periodTo);
bool limitInEnabled() const { return m_limitInEnabled; }
void setLimitInEnabled(bool enabled);
@ -48,6 +60,9 @@ public:
signals:
void enabledChanged();
void periodEnabledChanged();
void periodFromChanged();
void periodToChanged();
void limitInEnabledChanged();
void limitOutEnabledChanged();
void speedLimitInChanged();
@ -60,6 +75,11 @@ public slots:
private:
uint m_enabled : 1;
uint m_periodEnabled : 1;
uint m_periodFrom : 5;
uint m_periodTo : 5;
uint m_limitInEnabled : 1;
uint m_limitOutEnabled : 1;

View File

@ -122,7 +122,9 @@ void FortCommon::logStatTrafHeaderRead(const char *input,
void FortCommon::confAppPermsMaskInit(void *drvConf)
{
fort_conf_app_perms_mask_init((PFORT_CONF) drvConf);
PFORT_CONF conf = (PFORT_CONF) drvConf;
fort_conf_app_perms_mask_init(conf, conf->flags.group_bits);
}
bool FortCommon::confIpInRange(const void *drvConf, quint32 ip,
@ -166,6 +168,13 @@ bool FortCommon::confAppBlocked(const void *drvConf, int appIndex)
return fort_conf_app_blocked(conf, appIndex);
}
quint16 FortCommon::confAppPeriodBits(const void *drvConf, int hour)
{
const PFORT_CONF conf = (const PFORT_CONF) drvConf;
return fort_conf_app_period_bits(conf, hour, nullptr);
}
void FortCommon::provUnregister()
{
fort_prov_unregister(0);

View File

@ -55,6 +55,7 @@ public:
const QString &kernelPath);
static quint8 confAppGroupIndex(const void *drvConf, int appIndex);
static bool confAppBlocked(const void *drvConf, int appIndex);
static quint16 confAppPeriodBits(const void *drvConf, int hour);
static void provUnregister();
};

View File

@ -87,7 +87,7 @@ FortManager::~FortManager()
void FortManager::registerQmlTypes()
{
qmlRegisterUncreatableType<DriverManager>("com.fortfirewall", 1, 0, "DriverManager",
"Singleton");
"Singleton");
qmlRegisterUncreatableType<FortSettings>("com.fortfirewall", 1, 0, "FortSettings",
"Singleton");

Binary file not shown.

View File

@ -4,37 +4,37 @@
<context>
<name>ConfUtil</name>
<message>
<location filename="../util/conf/confutil.cpp" line="118"/>
<location filename="../util/conf/confutil.cpp" line="122"/>
<source>Bad Include IP address: %1</source>
<translation>Некорректный IP адрес для включения: %1</translation>
</message>
<message>
<location filename="../util/conf/confutil.cpp" line="126"/>
<location filename="../util/conf/confutil.cpp" line="130"/>
<source>Bad Exclude IP address: %1</source>
<translation>Некорректный IP адрес для исключения: %1</translation>
</message>
<message>
<location filename="../util/conf/confutil.cpp" line="137"/>
<location filename="../util/conf/confutil.cpp" line="141"/>
<source>Too many IP addresses</source>
<translation>Слишком много IP адресов</translation>
</message>
<message>
<location filename="../util/conf/confutil.cpp" line="57"/>
<location filename="../util/conf/confutil.cpp" line="59"/>
<source>Too many application paths</source>
<translation>Слишком много путей приложений</translation>
</message>
<message>
<location filename="../util/conf/confutil.cpp" line="159"/>
<location filename="../util/conf/confutil.cpp" line="165"/>
<source>Number of Application Groups must be &lt; %1</source>
<translation>Количество групп приложений должно быть &lt; %1</translation>
</message>
<message>
<location filename="../util/conf/confutil.cpp" line="171"/>
<location filename="../util/conf/confutil.cpp" line="177"/>
<source>Length of Application Group&apos;s Name must be &lt; %1</source>
<translation>Длина наименования группы приложения должна быть &lt; %1</translation>
</message>
<message>
<location filename="../util/conf/confutil.cpp" line="219"/>
<location filename="../util/conf/confutil.cpp" line="240"/>
<source>Length of Application&apos;s Path must be &lt; %1</source>
<translation>Длина пути приложения должна быть &lt; %1</translation>
</message>
@ -310,17 +310,22 @@
<translation>Сдвинуть направо</translation>
</message>
<message>
<location filename="../qml/pages/apps/AppsColumn.qml" line="46"/>
<location filename="../qml/pages/apps/AppsColumn.qml" line="47"/>
<source>Enabled</source>
<translation>Включено</translation>
</message>
<message>
<location filename="../qml/pages/apps/AppsColumn.qml" line="64"/>
<location filename="../qml/pages/apps/AppsColumn.qml" line="62"/>
<source>period, hours:</source>
<translation>период, часы</translation>
</message>
<message>
<location filename="../qml/pages/apps/AppsColumn.qml" line="113"/>
<source>Block</source>
<translation>Блокировать</translation>
</message>
<message>
<location filename="../qml/pages/apps/AppsColumn.qml" line="84"/>
<location filename="../qml/pages/apps/AppsColumn.qml" line="133"/>
<source>Allow</source>
<translation>Разрешить</translation>
</message>

View File

@ -9,7 +9,7 @@ ApplicationWindow {
width: 1025
height: 768
minimumWidth: 800
minimumWidth: 950
minimumHeight: 600
font.pixelSize: 16

View File

@ -42,6 +42,7 @@ ColumnLayout {
}
CheckBox {
id: cbEnabled
text: translationManager.trTrigger
&& qsTranslate("qml", "Enabled")
checked: appGroup.enabled
@ -51,6 +52,54 @@ ColumnLayout {
setConfFlagsEdited();
}
}
SpinDoubleRow {
Layout.maximumWidth: implicitWidth
enabled: cbEnabled.checked
checkBox {
text: translationManager.trTrigger
&& qsTranslate("qml", "period, hours:")
checked: appGroup.periodEnabled
onCheckedChanged: {
const value = checkBox.checked;
if (appGroup.periodEnabled == value)
return;
appGroup.periodEnabled = value;
setConfEdited();
}
}
field1 {
from: 0
to: 24
value: appGroup.periodFrom
onValueChanged: {
const value = field1.value;
if (appGroup.periodFrom == value)
return;
appGroup.periodFrom = value;
setConfEdited();
}
}
field2 {
from: 0
to: 24
value: appGroup.periodTo
onValueChanged: {
const value = field2.value;
if (appGroup.periodTo == value)
return;
appGroup.periodTo = value;
setConfEdited();
}
}
}
}
RowLayout {

View File

@ -46,11 +46,13 @@ int ConfUtil::write(const FirewallConf &conf, QByteArray &buf)
quint32 appPathsLen = 0;
QStringList appPaths;
numbers_arr_t appPerms;
quint8 appPeriodsCount = 0;
chars_arr_t appPeriods;
appgroups_map_t appGroupIndexes;
if (!parseAppGroups(conf.appGroupsList(),
appPaths, appPathsLen,
appPerms, appGroupIndexes))
appPaths, appPathsLen, appPerms,
appPeriods, appPeriodsCount, appGroupIndexes))
return false;
if (appPathsLen > FORT_CONF_APPS_LEN_MAX) {
@ -61,7 +63,8 @@ int ConfUtil::write(const FirewallConf &conf, QByteArray &buf)
// Fill the buffer
const int confIoSize = FORT_CONF_IO_CONF_OFF + FORT_CONF_DATA_OFF
+ addressGroupsSize
+ FORT_CONF_STR_DATA_SIZE(appGroupIndexes.size())
+ FORT_CONF_STR_DATA_SIZE(appGroupIndexes.size()) // appPerms
+ FORT_CONF_STR_DATA_SIZE(conf.appGroupsList().size() * 2) // appPeriods
+ appPaths.size() * sizeof(quint32)
+ FORT_CONF_STR_HEADER_SIZE(appPaths.size())
+ FORT_CONF_STR_DATA_SIZE(appPathsLen);
@ -70,7 +73,8 @@ int ConfUtil::write(const FirewallConf &conf, QByteArray &buf)
writeData(buf.data(), conf,
addressRanges, addressGroupOffsets,
appPaths, appPerms, appGroupIndexes);
appPaths, appPerms,
appPeriods, appPeriodsCount, appGroupIndexes);
return confIoSize;
}
@ -152,6 +156,8 @@ bool ConfUtil::parseAppGroups(const QList<AppGroup *> &appGroups,
QStringList &appPaths,
quint32 &appPathsLen,
numbers_arr_t &appPerms,
chars_arr_t &appPeriods,
quint8 &appPeriodsCount,
appgroups_map_t &appGroupIndexes)
{
const int groupsCount = appGroups.size();
@ -178,6 +184,21 @@ bool ConfUtil::parseAppGroups(const QList<AppGroup *> &appGroups,
|| !parseApps(appGroup->allowText(), false,
appPermsMap, appGroupIndexes, i))
return false;
// Enabled Period
{
qint8 periodFrom = 0, periodTo = 0;
if (appGroup->enabled() && appGroup->periodEnabled()) {
periodFrom = qint8(appGroup->periodFrom());
periodTo = qint8(appGroup->periodTo());
if (periodFrom != 0 || periodTo != 0) {
++appPeriodsCount;
}
}
appPeriods.append(periodFrom);
appPeriods.append(periodTo);
}
}
// Fill app. paths & perms arrays
@ -260,14 +281,16 @@ void ConfUtil::writeData(char *output, const FirewallConf &conf,
const numbers_arr_t &addressGroupOffsets,
const QStringList &appPaths,
const numbers_arr_t &appPerms,
const chars_arr_t &appPeriods,
quint8 appPeriodsCount,
const appgroups_map_t &appGroupIndexes)
{
PFORT_CONF_IO drvConfIo = (PFORT_CONF_IO) output;
PFORT_CONF drvConf = &drvConfIo->conf;
char *data = drvConf->data;
const quint32 appPathsSize = appPaths.size();
quint32 addrGroupsOff;
quint32 appPathsOff, appPermsOff, appGroupsOff;
quint32 addrGroupsOff, appGroupsOff;
quint32 appPathsOff, appPermsOff, appPeriodsOff;
#define CONF_DATA_OFFSET (data - drvConf->data)
addrGroupsOff = CONF_DATA_OFFSET;
@ -280,6 +303,9 @@ void ConfUtil::writeData(char *output, const FirewallConf &conf,
appPermsOff = CONF_DATA_OFFSET;
writeNumbers(&data, appPerms);
appPeriodsOff = CONF_DATA_OFFSET;
writeChars(&data, appPeriods);
appPathsOff = CONF_DATA_OFFSET;
writeStrings(&data, appPaths);
#undef CONF_DATA_OFFSET
@ -305,11 +331,13 @@ void ConfUtil::writeData(char *output, const FirewallConf &conf,
FortCommon::confAppPermsMaskInit(drvConf);
drvConf->apps_n = appPathsSize;
drvConf->app_periods_n = appPeriodsCount;
drvConf->addr_groups_off = addrGroupsOff;
drvConf->app_groups_off = appGroupsOff;
drvConf->app_perms_off = appPermsOff;
drvConf->app_periods_off = appPeriodsOff;
drvConf->apps_off = appPathsOff;
}
@ -368,7 +396,7 @@ void ConfUtil::writeAddressRange(char **data,
writeNumbers(data, addressRange.excludeRange().toArray());
}
void ConfUtil::writeNumbers(char **data, const QVector<quint32> &array)
void ConfUtil::writeNumbers(char **data, const numbers_arr_t &array)
{
const int arraySize = array.size() * sizeof(quint32);
@ -377,7 +405,7 @@ void ConfUtil::writeNumbers(char **data, const QVector<quint32> &array)
*data += arraySize;
}
void ConfUtil::writeChars(char **data, const QVector<qint8> &array)
void ConfUtil::writeChars(char **data, const chars_arr_t &array)
{
const int arraySize = array.size();

View File

@ -16,6 +16,7 @@ QT_FORWARD_DECLARE_CLASS(FirewallConf)
QT_FORWARD_DECLARE_STRUCT(fort_conf_limit)
using numbers_arr_t = QVector<quint32>;
using chars_arr_t = QVector<qint8>;
using addrranges_arr_t = QVarLengthArray<AddressRange, 2>;
@ -52,6 +53,8 @@ private:
QStringList &appPaths,
quint32 &appPathsLen,
numbers_arr_t &appPerms,
chars_arr_t &appPeriods,
quint8 &appPeriodsCount,
appgroups_map_t &appGroupIndexes);
bool parseApps(const QString &text, bool blocked,
@ -66,6 +69,8 @@ private:
const numbers_arr_t &addressGroupOffsets,
const QStringList &appPaths,
const numbers_arr_t &appPerms,
const chars_arr_t &appPeriods,
quint8 appPeriodsCount,
const appgroups_map_t &appGroupIndexes);
static quint16 writeLimits(struct fort_conf_limit *limits,
@ -76,8 +81,8 @@ private:
static void writeAddressRange(char **data,
const AddressRange &addressRange);
static void writeNumbers(char **data, const QVector<quint32> &array);
static void writeChars(char **data, const QVector<qint8> &array);
static void writeNumbers(char **data, const numbers_arr_t &array);
static void writeChars(char **data, const chars_arr_t &array);
static void writeStrings(char **data, const QStringList &list);
private:

View File

@ -2,6 +2,8 @@
#include <QLocale>
#include "../../common/util.h"
DateUtil::DateUtil(QObject *parent) :
QObject(parent)
{
@ -86,7 +88,5 @@ bool DateUtil::isHourBetween(qint32 unixHour, qint32 unixDay,
{
const int hour = unixHour - unixDay;
return fromHour <= toHour
? (hour >= fromHour && hour < toHour)
: (hour == 0 || hour >= fromHour || hour < toHour);
return is_hour_between(hour, fromHour, toHour);
}