Skip to content

Commit

Permalink
Prevent gateway scanner from scanning own host and local 127.x.x.x su…
Browse files Browse the repository at this point in the history
…bnet
  • Loading branch information
manup committed Sep 12, 2016
1 parent 91c6c09 commit 9fc4078
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion gateway_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ void GatewayScannerPrivate::initScanner()
if (a.protocol() == QAbstractSocket::IPv4Protocol)
{
quint32 ipv4 = a.toIPv4Address();
if ((ipv4 & 0xff000000UL) == 0x7f000000UL)
{
// 127.x.x.x
continue;
}

if (std::find(interfaces.begin(), interfaces.end(), ipv4) == interfaces.end())
{
interfaces.push_back(ipv4);
Expand Down Expand Up @@ -292,8 +298,16 @@ void GatewayScannerPrivate::queryNextIp()
return;
}


scanIp = interfaces.back();
scanPort = 80;

if (host == (scanIp & 0x000000fful))
{
DBG_Printf(DBG_INFO, "scan skip host .%u\n", host);
host++; // don't scan own ip
}

QString url;
url.sprintf("http://%u.%u.%u.%u:%u/description.xml",
((scanIp >> 24) & 0xff),
Expand All @@ -309,6 +323,5 @@ void GatewayScannerPrivate::queryNextIp()
QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
manager->parent(), SLOT(onError(QNetworkReply::NetworkError)));


startScanTimer(100, EventTimeout);
}

0 comments on commit 9fc4078

Please sign in to comment.