mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:35:10 +00:00
UI: Connections: Show block reason in tool-tip.
This commit is contained in:
parent
47488c0a55
commit
dd415e57bf
@ -47,3 +47,21 @@ void LogEntryBlockedIp::setRemoteIp(quint32 ip)
|
|||||||
{
|
{
|
||||||
m_remoteIp = ip;
|
m_remoteIp = ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString LogEntryBlockedIp::reasonToString(quint8 blockReason)
|
||||||
|
{
|
||||||
|
switch (blockReason) {
|
||||||
|
case ReasonIpInet:
|
||||||
|
return QObject::tr("Not allowed Internet address");
|
||||||
|
case ReasonReauth:
|
||||||
|
return QObject::tr("Old connection closed on startup");
|
||||||
|
case ReasonProgram:
|
||||||
|
return QObject::tr("Programs logic");
|
||||||
|
case ReasonAppGroupFound:
|
||||||
|
return QObject::tr("App. Group logic");
|
||||||
|
case ReasonAppGroupDefault:
|
||||||
|
return QObject::tr("App. Group default logic");
|
||||||
|
default:
|
||||||
|
return QObject::tr("Unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -44,6 +44,8 @@ public:
|
|||||||
quint32 remoteIp() const { return m_remoteIp; }
|
quint32 remoteIp() const { return m_remoteIp; }
|
||||||
void setRemoteIp(quint32 ip);
|
void setRemoteIp(quint32 ip);
|
||||||
|
|
||||||
|
static QString reasonToString(quint8 blockReason);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_inbound = false;
|
bool m_inbound = false;
|
||||||
quint8 m_blockReason = 0;
|
quint8 m_blockReason = 0;
|
||||||
|
@ -79,7 +79,7 @@ int AppListModel::columnCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
QVariant AppListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant AppListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Horizontal && (role == Qt::DisplayRole || role == Qt::ToolTipRole)) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0:
|
case 0:
|
||||||
return tr("Program");
|
return tr("Program");
|
||||||
@ -88,7 +88,7 @@ QVariant AppListModel::headerData(int section, Qt::Orientation orientation, int
|
|||||||
case 2:
|
case 2:
|
||||||
return tr("State");
|
return tr("State");
|
||||||
case 3:
|
case 3:
|
||||||
return tr("Bl.");
|
return (role == Qt::DisplayRole) ? tr("Bl.") : tr("Block scheduled");
|
||||||
case 4:
|
case 4:
|
||||||
return tr("Creation Time");
|
return tr("Creation Time");
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ int ConnListModel::columnCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
QVariant ConnListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant ConnListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Horizontal && (role == Qt::DisplayRole || role == Qt::ToolTipRole)) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0:
|
case 0:
|
||||||
return tr("Program");
|
return tr("Program");
|
||||||
@ -59,7 +59,7 @@ QVariant ConnListModel::headerData(int section, Qt::Orientation orientation, int
|
|||||||
case 4:
|
case 4:
|
||||||
return tr("Remote IP and Port");
|
return tr("Remote IP and Port");
|
||||||
case 5:
|
case 5:
|
||||||
return tr("Dir.");
|
return (role == Qt::DisplayRole) ? tr("Dir.") : tr("Direction");
|
||||||
case 6:
|
case 6:
|
||||||
return tr("Time");
|
return tr("Time");
|
||||||
}
|
}
|
||||||
@ -97,8 +97,16 @@ QVariant ConnListModel::data(const QModelIndex &index, int role) const
|
|||||||
return NetUtil::ip4ToText(connRow.localIp) + ':' + QString::number(connRow.localPort);
|
return NetUtil::ip4ToText(connRow.localIp) + ':' + QString::number(connRow.localPort);
|
||||||
case 4:
|
case 4:
|
||||||
return NetUtil::ip4ToText(connRow.remoteIp) + ':' + QString::number(connRow.remotePort);
|
return NetUtil::ip4ToText(connRow.remoteIp) + ':' + QString::number(connRow.remotePort);
|
||||||
case 5:
|
case 5: {
|
||||||
|
if (role == Qt::ToolTipRole) {
|
||||||
|
if (connRow.blocked) {
|
||||||
|
// Show block reason in tool-tip
|
||||||
|
const auto connBlock = getConnRowBlock(connRow.connId);
|
||||||
|
return LogEntryBlockedIp::reasonToString(connBlock.blockReason);
|
||||||
|
}
|
||||||
|
}
|
||||||
return connRow.inbound ? tr("In") : tr("Out");
|
return connRow.inbound ? tr("In") : tr("Out");
|
||||||
|
}
|
||||||
case 6:
|
case 6:
|
||||||
return connRow.connTime;
|
return connRow.connTime;
|
||||||
}
|
}
|
||||||
@ -149,6 +157,14 @@ const ConnRow &ConnListModel::connRowAt(int row) const
|
|||||||
return m_connRow;
|
return m_connRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConnRowBlock ConnListModel::getConnRowBlock(qint64 connId) const
|
||||||
|
{
|
||||||
|
static const char *const sql = "SELECT block_reason FROM conn_block"
|
||||||
|
" WHERE conn_id = ?1";
|
||||||
|
|
||||||
|
return { quint8(sqliteDb()->executeEx(sql, { connId }).toInt()) };
|
||||||
|
}
|
||||||
|
|
||||||
void ConnListModel::clear()
|
void ConnListModel::clear()
|
||||||
{
|
{
|
||||||
statManager()->deleteConns();
|
statManager()->deleteConns();
|
||||||
|
@ -30,6 +30,11 @@ struct ConnRow : TableRow
|
|||||||
QDateTime connTime;
|
QDateTime connTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ConnRowBlock
|
||||||
|
{
|
||||||
|
quint8 blockReason = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class ConnListModel : public TableSqlModel
|
class ConnListModel : public TableSqlModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -55,6 +60,8 @@ public:
|
|||||||
|
|
||||||
const ConnRow &connRowAt(int row) const;
|
const ConnRow &connRowAt(int row) const;
|
||||||
|
|
||||||
|
ConnRowBlock getConnRowBlock(qint64 connId) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ int TrafListModel::columnCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
QVariant TrafListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant TrafListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Horizontal && (role == Qt::DisplayRole || role == Qt::ToolTipRole)) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0:
|
case 0:
|
||||||
return tr("Date");
|
return tr("Date");
|
||||||
|
@ -36,7 +36,7 @@ int ZoneListModel::columnCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
QVariant ZoneListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant ZoneListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Horizontal && (role == Qt::DisplayRole || role == Qt::ToolTipRole)) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0:
|
case 0:
|
||||||
return tr("Zone");
|
return tr("Zone");
|
||||||
|
@ -36,7 +36,7 @@ int TaskListModel::columnCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
QVariant TaskListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant TaskListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Horizontal && (role == Qt::DisplayRole || role == Qt::ToolTipRole)) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0:
|
case 0:
|
||||||
return tr("Name");
|
return tr("Name");
|
||||||
|
Loading…
Reference in New Issue
Block a user