Hi Bo,
I think it was possible to receive a NodeAddress in a Pong packet from a Gnutella leaf that has a zero IP address and non-zero port. In that case we can ignore the information as we already know the leaf listen port from the handshake but there might be some other cases as well… I think it’s an interesting idea to zero invalid NodeAddresses though! This issue seems to be similar to the one we had with Packet and isValid(). Any other ideas?
Regards,
Peter
Bob wrote:Hi everyone,
By doing the unit test of class NodeCache, I have found, if I try to add a node with the address 0.0.0.0:200, it will be added successfully.
The assert Q_ASSERT (nodeInfo.address != NodeAddress::Null); will not find it, because the NodeAddress::Null is the address 0.0.0.0:0.
But 0.0.0.0:200 is also an invalid address, and there are many other invalid addresses. Because these addresses are received from other peers, so they should be checked, at least they should be valid.
I think we can modify the constructor of the class NodeAddress. It sets all invalid addresses to 0.0.0.0:0. Then the “users” of class NodeCache should verify the address, before adding it to the cache.
Best regards,
Bo
