add the port type to the PortInfo struct

This commit is contained in:
Luke De Mouy
2016-01-07 16:55:04 -07:00
parent 26f51d6822
commit 5cc11be9e6
2 changed files with 8 additions and 1 deletions

View File

@@ -22,6 +22,12 @@ PortLookUp::PortInfo PortLookUp::LookUpPort(int portNumber, QString portType)
//the port number is valid so set it
returnValue.Port = portNumber;
//make sure that the portType is cased in lower to match the service file and
//then store it in the returnValue, since there isn't a huge point in checking
//the validitiy of the type since /etc/services lists more than udp/tcp
portType = portType.toLower();
returnValue.PortType = portType;
//Check to see if it's a recommended port
returnValue.Recommended = false;
for(int i = 0; i < recommendedPortsSize; i++)
@@ -35,7 +41,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.toLower()+")/g"));
QStringList port = portStrings->filter(QRegExp("/\\b("+QString::number(portNumber)+"\\/"+portType+")/g"));
if(port.size() > 0)
{

View File

@@ -15,6 +15,7 @@ class PortLookUp
{
struct PortInfo{
int Port;
QString PortType;
QString Keyword;
QString Description;
bool Recommended;