mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:15:07 +00:00
UI: Add "Prompt" filter mode
This commit is contained in:
parent
177c6fcaaf
commit
98af3bd1c5
@ -27,6 +27,7 @@ typedef struct fort_conf_flags
|
||||
UINT32 stop_traffic : 1;
|
||||
UINT32 stop_inet_traffic : 1;
|
||||
UINT32 allow_all_new : 1;
|
||||
UINT32 prompt : 1;
|
||||
UINT32 app_block_all : 1;
|
||||
UINT32 app_allow_all : 1;
|
||||
UINT32 log_blocked : 1;
|
||||
@ -35,6 +36,7 @@ typedef struct fort_conf_flags
|
||||
UINT32 log_allowed_ip : 1;
|
||||
UINT32 log_blocked_ip : 1;
|
||||
UINT32 group_apply_child : 1;
|
||||
/* UINT32 reserved : 1; */
|
||||
|
||||
UINT32 group_bits : 16;
|
||||
} FORT_CONF_FLAGS, *PFORT_CONF_FLAGS;
|
||||
|
@ -15,6 +15,7 @@ FirewallConf::FirewallConf(Settings *settings, QObject *parent) :
|
||||
m_stopTraffic(false),
|
||||
m_stopInetTraffic(false),
|
||||
m_allowAllNew(false),
|
||||
m_prompt(false),
|
||||
m_logBlocked(false),
|
||||
m_logStat(false),
|
||||
m_logStatNoFilter(false),
|
||||
@ -63,6 +64,11 @@ void FirewallConf::setAllowAllNew(bool allowAllNew)
|
||||
m_allowAllNew = allowAllNew;
|
||||
}
|
||||
|
||||
void FirewallConf::setPrompt(bool prompt)
|
||||
{
|
||||
m_prompt = prompt;
|
||||
}
|
||||
|
||||
void FirewallConf::setLogBlocked(bool logBlocked)
|
||||
{
|
||||
m_logBlocked = logBlocked;
|
||||
@ -103,38 +109,42 @@ void FirewallConf::setAppAllowAll(bool appAllowAll)
|
||||
|
||||
int FirewallConf::filterModeIndex() const
|
||||
{
|
||||
return m_appBlockAll ? (m_allowAllNew ? 0 : 1) : (m_appAllowAll ? 2 : 3);
|
||||
return m_appBlockAll ? (m_allowAllNew ? 0 : 1) : (m_appAllowAll ? 2 : (m_prompt ? 3 : 4));
|
||||
}
|
||||
|
||||
void FirewallConf::setFilterModeIndex(int index)
|
||||
{
|
||||
m_allowAllNew = false;
|
||||
m_prompt = false;
|
||||
m_appBlockAll = false;
|
||||
m_appAllowAll = false;
|
||||
|
||||
switch (index) {
|
||||
case 0: {
|
||||
m_allowAllNew = true;
|
||||
Q_FALLTHROUGH();
|
||||
}
|
||||
m_appBlockAll = true;
|
||||
} break;
|
||||
case 1: {
|
||||
m_appBlockAll = true;
|
||||
} break;
|
||||
case 2: {
|
||||
m_appAllowAll = true;
|
||||
} break;
|
||||
case 3: {
|
||||
m_prompt = true;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList FirewallConf::filterModeNames()
|
||||
{
|
||||
return { tr("Auto-Learn"), tr("Block, if not allowed"), tr("Allow, if not blocked"),
|
||||
tr("Ignore, if not blocked or allowed") };
|
||||
return { tr("Auto-Learn"), tr("Block"), tr("Allow"), tr("Prompt"), tr("Ignore") };
|
||||
}
|
||||
|
||||
QStringList FirewallConf::filterModeIconPaths()
|
||||
{
|
||||
return { ":/icons/error.png", ":/icons/deny.png", ":/icons/accept.png", QString() };
|
||||
return { ":/icons/error.png", ":/icons/deny.png", ":/icons/accept.png", ":/icons/help.png",
|
||||
QString() };
|
||||
}
|
||||
|
||||
void FirewallConf::setActivePeriodEnabled(bool activePeriodEnabled)
|
||||
@ -315,6 +325,7 @@ void FirewallConf::copyFlags(const FirewallConf &o)
|
||||
m_stopTraffic = o.stopTraffic();
|
||||
m_stopInetTraffic = o.stopInetTraffic();
|
||||
m_allowAllNew = o.allowAllNew();
|
||||
m_prompt = o.prompt();
|
||||
|
||||
m_logBlocked = o.logBlocked();
|
||||
m_logStat = o.logStat();
|
||||
@ -361,6 +372,7 @@ QVariant FirewallConf::flagsToVariant() const
|
||||
map["stopTraffic"] = stopTraffic();
|
||||
map["stopInetTraffic"] = stopInetTraffic();
|
||||
map["allowAllNew"] = allowAllNew();
|
||||
map["prompt"] = prompt();
|
||||
|
||||
map["logBlocked"] = logBlocked();
|
||||
map["logStat"] = logStat();
|
||||
@ -391,6 +403,7 @@ void FirewallConf::flagsFromVariant(const QVariant &v)
|
||||
m_stopTraffic = map["stopTraffic"].toBool();
|
||||
m_stopInetTraffic = map["stopInetTraffic"].toBool();
|
||||
m_allowAllNew = map["allowAllNew"].toBool();
|
||||
m_prompt = map["prompt"].toBool();
|
||||
|
||||
m_logBlocked = map["logBlocked"].toBool();
|
||||
m_logStat = map["logStat"].toBool();
|
||||
|
@ -61,6 +61,9 @@ public:
|
||||
bool allowAllNew() const { return m_allowAllNew; }
|
||||
void setAllowAllNew(bool allowAllNew);
|
||||
|
||||
bool prompt() const { return m_prompt; }
|
||||
void setPrompt(bool prompt);
|
||||
|
||||
bool logBlocked() const { return m_logBlocked; }
|
||||
void setLogBlocked(bool logBlocked);
|
||||
|
||||
@ -173,6 +176,7 @@ private:
|
||||
uint m_stopTraffic : 1;
|
||||
uint m_stopInetTraffic : 1;
|
||||
uint m_allowAllNew : 1;
|
||||
uint m_prompt : 1;
|
||||
|
||||
uint m_logBlocked : 1;
|
||||
uint m_logStat : 1;
|
||||
|
@ -27,6 +27,7 @@
|
||||
<file>icons/folder.png</file>
|
||||
<file>icons/github.png</file>
|
||||
<file>icons/global_telecom.png</file>
|
||||
<file>icons/help.png</file>
|
||||
<file>icons/hostname.png</file>
|
||||
<file>icons/ip.png</file>
|
||||
<file>icons/ip_class.png</file>
|
||||
|
@ -312,6 +312,7 @@ void FortSettings::readConfIni(FirewallConf &conf) const
|
||||
conf.setStopTraffic(iniBool("stopTraffic"));
|
||||
conf.setStopInetTraffic(iniBool("stopInetTraffic"));
|
||||
conf.setAllowAllNew(iniBool("allowAllNew", true));
|
||||
conf.setPrompt(iniBool("prompt"));
|
||||
conf.setLogBlocked(iniBool("logBlocked", true));
|
||||
conf.setLogStat(iniBool("logStat", true));
|
||||
conf.setLogStatNoFilter(iniBool("logStatNoFilter", true));
|
||||
@ -341,6 +342,7 @@ void FortSettings::writeConfIni(const FirewallConf &conf)
|
||||
setIniValue("stopTraffic", conf.stopTraffic());
|
||||
setIniValue("stopInetTraffic", conf.stopInetTraffic());
|
||||
setIniValue("allowAllNew", conf.allowAllNew());
|
||||
setIniValue("prompt", conf.prompt());
|
||||
setIniValue("logBlocked", conf.logBlocked());
|
||||
setIniValue("logStat", conf.logStat());
|
||||
setIniValue("logStatNoFilter", conf.logStatNoFilter());
|
||||
|
BIN
src/ui/icons/help.png
Normal file
BIN
src/ui/icons/help.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
@ -31,6 +31,7 @@ void writeConfFlags(const FirewallConf &conf, PFORT_CONF_FLAGS confFlags)
|
||||
confFlags->stop_traffic = conf.stopTraffic();
|
||||
confFlags->stop_inet_traffic = conf.stopInetTraffic();
|
||||
confFlags->allow_all_new = conf.allowAllNew();
|
||||
confFlags->prompt = conf.prompt();
|
||||
|
||||
confFlags->app_block_all = conf.appBlockAll();
|
||||
confFlags->app_allow_all = conf.appAllowAll();
|
||||
|
Loading…
Reference in New Issue
Block a user