ippdiscovery: resolve unknown targets
If a target entry was included in an answer, but not its IP, query about that target.
This commit is contained in:
parent
de1d88686f
commit
218f74d41e
1 changed files with 17 additions and 5 deletions
|
@ -150,7 +150,8 @@ void IppDiscovery::readPendingDatagrams()
|
|||
QHostAddress sender;
|
||||
quint16 senderPort;
|
||||
|
||||
QStringList ipp_ptrs;
|
||||
QStringList new_ipp_ptrs;
|
||||
QStringList new_targets;
|
||||
|
||||
socket->readDatagram((char*)(resp.raw()), size, &sender, &senderPort);
|
||||
sender = QHostAddress(sender.toIPv4Address());
|
||||
|
@ -182,7 +183,7 @@ void IppDiscovery::readPendingDatagrams()
|
|||
QString tmpname = get_addr(resp).join(".");
|
||||
if(aaddr.endsWith("_ipp._tcp.local"))
|
||||
{
|
||||
ipp_ptrs.append(tmpname);
|
||||
new_ipp_ptrs.append(tmpname);
|
||||
}
|
||||
}
|
||||
else if(atype == TXT)
|
||||
|
@ -206,6 +207,7 @@ void IppDiscovery::readPendingDatagrams()
|
|||
QString target = get_addr(resp).join(".");
|
||||
_ports[aaddr] = port;
|
||||
_targets[aaddr] = target;
|
||||
new_targets.append(target);
|
||||
}
|
||||
else if(atype == A)
|
||||
{
|
||||
|
@ -227,25 +229,35 @@ void IppDiscovery::readPendingDatagrams()
|
|||
qDebug() << e.what();
|
||||
return;
|
||||
}
|
||||
qDebug() << "new ipp ptrs" << ipp_ptrs;
|
||||
qDebug() << "new ipp ptrs" << new_ipp_ptrs;
|
||||
qDebug() << "ipp ptrs" << _ipp;
|
||||
qDebug() << "rps" << _rps;
|
||||
qDebug() << "ports" << _ports;
|
||||
qDebug() << "new targets" << new_targets;
|
||||
qDebug() << "targets" << _targets;
|
||||
qDebug() << "AAs" << _AAs;
|
||||
qDebug() << "AAAAs" << _AAAAs;
|
||||
|
||||
for(QStringList::Iterator it = ipp_ptrs.begin(); it != ipp_ptrs.end(); it++)
|
||||
for(QStringList::Iterator it = new_ipp_ptrs.begin(); it != new_ipp_ptrs.end(); it++)
|
||||
{
|
||||
if(!_ipp.contains(*it))
|
||||
{
|
||||
_ipp.append(*it);
|
||||
}
|
||||
if(!_ports.contains(*it) || !_targets.contains(*it) || !_rps.contains(*it))
|
||||
// If pointer does not resolve to a target or is missing information, query about it
|
||||
if( !_targets.contains(*it) || !_ports.contains(*it) || !_rps.contains(*it))
|
||||
{ // if the PTR doesn't already resolve, ask for everything about it
|
||||
sendQuery(ALL, it->split('.'));
|
||||
}
|
||||
}
|
||||
for(QStringList::Iterator it = new_targets.begin(); it != new_targets.end(); it++)
|
||||
{
|
||||
// If target does not resolve to an address, query about it
|
||||
if(!_AAs.contains(*it))
|
||||
{
|
||||
sendQuery(ALL, it->split('.'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
this->update();
|
||||
|
|
Loading…
Reference in a new issue