UI: Prepare StatisticsPage.

This commit is contained in:
Nodir Temirkhodjaev 2017-11-20 12:50:16 +05:00
parent 078df4307a
commit 74e09b3a43
11 changed files with 107 additions and 21 deletions

View File

@ -207,7 +207,8 @@ fort_callout_classify_v4 (const FWPS_INCOMING_VALUES0 *inFixedValues,
if (!blocked) {
if (ip_included && conf_flags.log_stat) {
fort_stat_flow_associate(inMetaValues->flowHandle);
fort_stat_flow_associate(inMetaValues->flowHandle,
g_device->flow4_id, (UINT32) inMetaValues->processId);
}
goto permit;
}
@ -321,7 +322,7 @@ fort_callout_install (PDEVICE_OBJECT device)
/* IPv4 flow callout */
c.calloutKey = FORT_GUID_CALLOUT_FLOW_V4;
c.classifyFn = fort_callout_flow_v4;
c.classifyFn = fort_callout_flow_classify_v4;
c.flowDeleteFn = fort_callout_flow_delete_v4;
c.flags = FWP_CALLOUT_FLAG_CONDITIONAL_ON_FLOW;

View File

@ -1,15 +1,19 @@
/* Fort Firewall Usage Statistics */
static void
fort_stat_flow_associate(UINT64 flowId)
fort_stat_flow_associate (UINT64 flowId,
UINT32 calloutId,
UINT32 processId)
{
//DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
// "FORT: Classify V4: %d %d %d\n", FWPS_IS_METADATA_FIELD_PRESENT(
// inMetaValues, FWPS_METADATA_FIELD_FLOW_HANDLE),
// inMetaValues->flowHandle, (UINT32) flowContext);
NTSTATUS status;
//const NTSTATUS status = FwpsFlowAssociateContext0(
// flowId, FWPM_LAYER_STREAM_V4, FORT_GUID_CALLOUT_FLOW_V4, 1);
status = FwpsFlowAssociateContext0(
flowId, FWPS_LAYER_STREAM_V4, calloutId, processId);
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"FORT: flow +: %d %d\n", flowId, processId);
//STATUS_OBJECT_NAME_EXISTS
}
static void
@ -17,14 +21,25 @@ fort_callout_flow_delete_v4 (UINT16 layerId,
UINT32 calloutId,
UINT64 flowContext)
{
UNUSED(layerId);
UNUSED(calloutId);
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"FORT: flow -: %d\n", (UINT32) flowContext);
}
static void
fort_callout_flow_v4 (const FWPS_INCOMING_VALUES0 *inFixedValues,
const FWPS_INCOMING_METADATA_VALUES0 *inMetaValues,
void *layerData,
const FWPS_FILTER0 *filter,
UINT64 flowContext,
FWPS_CLASSIFY_OUT0 *classifyOut)
fort_callout_flow_classify_v4 (const FWPS_INCOMING_VALUES0 *inFixedValues,
const FWPS_INCOMING_METADATA_VALUES0 *inMetaValues,
FWPS_STREAM_CALLOUT_IO_PACKET0 *packet,
const FWPS_FILTER0 *filter,
UINT64 flowContext,
FWPS_CLASSIFY_OUT0 *classifyOut)
{
FWPS_STREAM_DATA0 *streamData = packet->streamData;
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"FORT: flow >: %d %d %d\n", inMetaValues->flowHandle, flowContext, streamData->dataLength);
classifyOut->actionType = FWP_ACTION_CONTINUE;
}

View File

@ -142,6 +142,7 @@ void FirewallConf::copyFlags(const FirewallConf &o)
void FirewallConf::copyTempFlags(const FirewallConf &o)
{
setLogBlocked(o.logBlocked());
setLogStat(o.logStat());
}
QVariant FirewallConf::toVariant() const

View File

@ -6,6 +6,7 @@
<file>images/application_double.png</file>
<file>images/application_edit.png</file>
<file>images/cancel.png</file>
<file>images/chart_line.png</file>
<file>images/clock.png</file>
<file>images/cog.png</file>
<file>images/cross.png</file>

View File

@ -11,6 +11,7 @@
<file>qml/pages/MainPage.qml</file>
<file>qml/pages/OptionsPage.qml</file>
<file>qml/pages/SchedulePage.qml</file>
<file>qml/pages/StatisticsPage.qml</file>
<file>qml/pages/addresses/AddressesColumn.qml</file>
<file>qml/pages/apps/AppsColumn.qml</file>
<file>qml/pages/apps/AppsTextColumn.qml</file>

View File

@ -306,6 +306,13 @@ void FortManager::setLogBlocked(bool enable)
updateDriverConfFlags(m_firewallConf);
}
void FortManager::setLogStat(bool enable)
{
m_firewallConf->setLogStat(enable);
updateDriverConfFlags(m_firewallConf);
}
void FortManager::setLanguage(int language)
{
if (!TranslationManager::instance()->switchLanguage(language))

View File

@ -55,6 +55,7 @@ public slots:
bool applyConf(bool onlyFlags = false);
void setLogBlocked(bool enable);
void setLogStat(bool enable);
void setLanguage(int language);

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

View File

@ -9,18 +9,18 @@ BasePage {
readonly property LogManager logManager: fortManager.logManager
readonly property AppBlockedModel appBlockedModel: logManager.appBlockedModel
property bool logReadingEnabled: false
property bool logBlockedEnabled: false
property bool addressResolvingEnabled: false
readonly property string currentAppPath:
(appListView.currentIndex >= 0 && appListView.currentItem)
? appListView.currentItem.appPath : ""
function switchLogReading(enable) {
if (logReadingEnabled === enable)
function switchLogBlocked(enable) {
if (logBlockedEnabled === enable)
return;
logReadingEnabled = enable;
logBlockedEnabled = enable;
fortManager.setLogBlocked(enable);
}
@ -42,7 +42,7 @@ BasePage {
target: mainPage
onClosed: {
switchResolveAddresses(false);
switchLogReading(false);
switchLogBlocked(false);
}
}
@ -77,7 +77,7 @@ BasePage {
font.weight: Font.DemiBold
text: translationManager.dummyBool
&& qsTranslate("qml", "Log Blocked Applications")
onToggled: switchLogReading(checked)
onToggled: switchLogBlocked(checked)
}
}

View File

@ -67,6 +67,11 @@ Page {
text: translationManager.dummyBool
&& qsTranslate("qml", "Blocked")
}
TabButton {
icon.source: "qrc:/images/chart_line.png"
text: translationManager.dummyBool
&& qsTranslate("qml", "Statistics")
}
}
SwipeView {
@ -79,6 +84,7 @@ Page {
ApplicationsPage {}
SchedulePage {}
BlockedPage {}
StatisticsPage {}
}
footer: Pane {

View File

@ -0,0 +1,53 @@
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import "../controls"
import com.fortfirewall 1.0
BasePage {
readonly property LogManager logManager: fortManager.logManager
property bool logStatisticsEnabled: false
function switchLogStatistics(enable) {
if (logStatisticsEnabled === enable)
return;
logStatisticsEnabled = enable;
fortManager.setLogStat(enable);
}
Connections {
target: mainPage
onClosed: {
switchLogStatistics(false);
}
}
ColumnLayout {
anchors.fill: parent
spacing: 10
RowLayout {
Item {
Layout.fillWidth: true
}
Switch {
id: cbShowBlockedApps
font.weight: Font.DemiBold
text: translationManager.dummyBool
&& qsTranslate("qml", "Collect Usage Statistics")
onToggled: switchLogStatistics(checked)
}
}
Frame {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
}
}
}