diff --git a/src/comm/UDPLink.cc b/src/comm/UDPLink.cc index b2ba5ea..36b2a1a 100644 --- a/src/comm/UDPLink.cc +++ b/src/comm/UDPLink.cc @@ -160,7 +160,6 @@ QString UDPLink::getName() const void UDPLink::_writeBytes(const QByteArray data) { -<<<<<<< HEAD if (!_socket) return; // Send to all manually targeted systems @@ -168,37 +167,6 @@ void UDPLink::_writeBytes(const QByteArray data) // Skip it if it's part of the session clients below if(!contains_target(_sessionTargets, target->address, target->port)) { _writeDataGram(data, target); -======= - if (_socket) { - QStringList goneHosts; - // Send to all connected systems - QString host; - int port; - if(_udpConfig->firstHost(host, port)) { - do { - QHostAddress currentHost(host); - if(_socket->writeDatagram(data, currentHost, (quint16)port) < 0) { - // This host is gone. Add to list to be removed - // We should keep track of hosts that were manually added (static) and - // hosts that were added because we heard from them (dynamic). Only - // dynamic hosts should be removed and even then, after a few tries, not - // the first failure. In the mean time, we don't remove anything. - if(REMOVE_GONE_HOSTS) { - goneHosts.append(host); - } - } else { - // Only log rate if data actually got sent. Not sure about this as - // "host not there" takes time too regardless of size of data. In fact, - // 1 byte or "UDP frame size" bytes are the same as that's the data - // unit sent by UDP. - _logOutputDataRate(data.size(), QDateTime::currentMSecsSinceEpoch()); - } - } while (_udpConfig->nextHost(host, port)); - //-- Remove hosts that are no longer there - foreach (const QString& ghost, goneHosts) { - _udpConfig->removeHost(ghost); - } ->>>>>>> b4f4085c6733b934358b00389d734600eab87bf7 } } // Send to all connected systems @@ -226,31 +194,23 @@ void UDPLink::_writeDataGram(const QByteArray data, const UDPCLient* target) void UDPLink::readBytes() { if (_socket) { - QByteArray databuffer; - while (_socket->hasPendingDatagrams()) { - QByteArray datagram; - datagram.resize(_socket->pendingDatagramSize()); - QHostAddress sender; - quint16 senderPort; - _socket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort); - databuffer.append(datagram); - //-- Wait a bit before sending it over - if(databuffer.size() > 10 * 1024) { - emit bytesReceived(this, databuffer); - databuffer.clear(); - } - _logInputDataRate(datagram.length(), QDateTime::currentMSecsSinceEpoch()); - // TODO This doesn't validade the sender. Anything sending UDP packets to this port gets - // added to the list and will start receiving datagrams from here. Even a port scanner - // would trigger this. - // Add host to broadcast list if not yet present, or update its port - _udpConfig->addHost(sender.toString(), (int)senderPort); - } - //-- Send whatever is left - if(databuffer.size()) { + return; + } + + QByteArray databuffer; + while (_socket->hasPendingDatagrams()) + { + QByteArray datagram; + datagram.resize(_socket->pendingDatagramSize()); + QHostAddress sender; + quint16 senderPort; + _socket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort); + databuffer.append(datagram); + //-- Wait a bit before sending it over + if(databuffer.size() > 10 * 1024) { emit bytesReceived(this, databuffer); + databuffer.clear(); } -<<<<<<< HEAD _logInputDataRate(datagram.length(), QDateTime::currentMSecsSinceEpoch()); // TODO: This doesn't validade the sender. Anything sending UDP packets to this port gets // added to the list and will start receiving datagrams from here. Even a port scanner @@ -269,8 +229,6 @@ void UDPLink::readBytes() //-- Send whatever is left if(databuffer.size()) { emit bytesReceived(this, databuffer); -======= ->>>>>>> b4f4085c6733b934358b00389d734600eab87bf7 } }