mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Refactor to use Range Based For Loops since C++11 is enabled, also add
in LoadOpenPorts to the function to reset to the default config, so that we have the correct set of open ports.
This commit is contained in:
@@ -37,9 +37,9 @@ PortInfo Firewall::LookUpPort(int port, QString type)
|
||||
|
||||
//Check to see if it's a recommended port
|
||||
returnValue.Recommended = false;
|
||||
for(int i = 0; i < recommendedPortsSize; i++)
|
||||
for(int recommendedPort : recommendedPorts)
|
||||
{
|
||||
if (port == recommendedPorts[i])
|
||||
if (port == recommendedPort)
|
||||
{
|
||||
returnValue.Recommended = true;
|
||||
}
|
||||
@@ -151,6 +151,8 @@ void Firewall::RestoreDefaults()
|
||||
system("mv /etc/ipfw.openports /etc/ipfw.openports.previous");
|
||||
//refresh/restart the rules files
|
||||
system("sh /usr/local/share/pcbsd/scripts/reset-firewall");
|
||||
|
||||
LoadOpenPorts();
|
||||
}
|
||||
|
||||
Firewall::Firewall()
|
||||
@@ -211,9 +213,9 @@ void Firewall::SaveOpenPorts()
|
||||
//Convert to file format
|
||||
std::sort(openports.begin(), openports.end()); //make sure they are still sorted by port
|
||||
QStringList fileout;
|
||||
for(int i=0; i<openports.length(); i++){
|
||||
fileout.append("#" + openports[i].Keyword + ": " + openports[i].Description + "\n" +
|
||||
openports[i].Type +" "+QString::number(openports[i].Port));
|
||||
for(PortInfo port : openports){
|
||||
fileout.append("#" + port.Keyword + ": " + port.Description + "\n" +
|
||||
port.Type +" "+QString::number(port.Port));
|
||||
}
|
||||
//Always make sure that the file always ends with a newline
|
||||
if(!fileout.isEmpty()){ fileout << ""; }
|
||||
|
||||
@@ -29,8 +29,7 @@ struct PortInfo{
|
||||
{ return !(lhs == rhs);}
|
||||
};
|
||||
|
||||
const static int recommendedPorts[] = {22, 80};
|
||||
const static int recommendedPortsSize = 2;
|
||||
const static QVector<int> recommendedPorts = {22, 80};
|
||||
class Firewall
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user