mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Move PortInfo struct out of PortLookUp class, and fiddled with the regex
to make it actually work based on testing. The filter operation now will pickup things like 522/tcp in the QStringList if you're searching for 22/tcp, but testing seems to indicate that just taking the first one in the list works for getting what we want.
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
#include "portlookup.h"
|
||||
#include <QtCore>
|
||||
|
||||
using namespace sysadm;
|
||||
PortLookUp::PortInfo PortLookUp::LookUpPort(int portNumber, QString portType)
|
||||
PortInfo PortLookUp::LookUpPort(int portNumber, QString portType)
|
||||
{
|
||||
//Make sure that the port is valid
|
||||
if (portNumber < 0 || portNumber > 65535)
|
||||
@@ -41,8 +40,7 @@ PortLookUp::PortInfo PortLookUp::LookUpPort(int portNumber, QString portType)
|
||||
//Check to see if the port number is listed. The format in the file
|
||||
// is portname/portType. ex.: 22/tcp
|
||||
|
||||
QStringList port = portStrings->filter(QRegExp("/\\b("+QString::number(portNumber)+"\\/"+portType+")/g"));
|
||||
|
||||
QStringList port = portStrings->filter(QString::number(portNumber) + "/" + portType);
|
||||
if(port.size() > 0)
|
||||
{
|
||||
//grab the first one, there may be duplicates due to colliding ports in the /etc/services file
|
||||
|
||||
@@ -9,17 +9,19 @@
|
||||
#include <QtCore>
|
||||
namespace sysadm
|
||||
{
|
||||
struct PortInfo{
|
||||
int Port;
|
||||
QString PortType;
|
||||
QString Keyword;
|
||||
QString Description;
|
||||
bool Recommended;
|
||||
};
|
||||
|
||||
const static int recommendedPorts[] = {22, 80};
|
||||
const static int recommendedPortsSize = 2;
|
||||
class PortLookUp
|
||||
{
|
||||
struct PortInfo{
|
||||
int Port;
|
||||
QString PortType;
|
||||
QString Keyword;
|
||||
QString Description;
|
||||
bool Recommended;
|
||||
};
|
||||
|
||||
public:
|
||||
/**
|
||||
* @description Returns a structure containing information about the port
|
||||
|
||||
Reference in New Issue
Block a user