Commit 8a3fc510 authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Fix UFW backend with the new Protocol API

parent ab31a204
......@@ -49,6 +49,17 @@ bool FirewallClient::isTcpAndUdp(int protocolIdx)
return m_currentBackend->isTcpAndUdp(protocolIdx);
}
int FirewallClient::indexOfProtocol(const QString& protocol)
{
const QStringList protocolList = m_currentBackend->knownProtocols();
for(int i = 0; i < m_currentBackend->knownProtocols().size(); i++) {
if (protocolList[i].toLower() == protocol.toLower()) {
return i;
}
}
return -1;
}
QStringList FirewallClient::knownInterfaces()
{
QStringList interface_names({i18n("Any")});
......
......@@ -59,6 +59,7 @@ public:
Q_INVOKABLE static QStringList knownProtocols();
Q_INVOKABLE static QStringList knownInterfaces();
Q_INVOKABLE static bool isTcpAndUdp(int protocolIdx);
static int indexOfProtocol(const QString& protocol);
Q_INVOKABLE void refresh();
......
......@@ -149,7 +149,8 @@ void Profile::load(QIODevice *device)
const auto action = Types::toPolicy(attr.value(QLatin1String("action")).toString());
// TODO: Check that this is ok.
const auto protocol = FirewallClient::knownProtocols().indexOf(attr.value(QLatin1String("protocol")));
const auto protocol = FirewallClient::indexOfProtocol(attr.value(QLatin1String("protocol")).toString());
qDebug() << "Reading protocol from profile:" << protocol << attr.value(QLatin1String("protocol"));
const auto logType = Types::toLogging(attr.value(QLatin1String("logtype")).toString());
......
......@@ -182,6 +182,7 @@ Rule::Rule()
QString Rule::fromStr() const
{
qDebug() << "Before Crashing" << m_protocol;
return modify(m_sourceAddress, m_sourcePort, m_sourceApplication, m_interfaceIn, m_protocol);
}
......
......@@ -10,6 +10,7 @@
#include <QObject>
#include <QString>
#include <QDebug>
#include "types.h"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment