litecoin-project/litecoin — pull request #81 by wtogami (2013-10-26 21:24:21+00:00)
Title: [net] Don't use third-party "what is my IP" services.

**Backport from Bitcoin's https://github.com/bitcoin/bitcoin/pull/3088**

This patch eliminates the privacy and reliability problematic use
of centralized web services for discovering the node's addresses
for advertisement.

The Bitcoin protocol already allows your peers to tell you what
IP they think you have, but this data isn't trustworthy since
they could lie. So the challenge is using it without creating a
DOS vector.

To accomplish this we adopt an approach similar to the one used
by P2Pool: If we're announcing and don't have a better address
discovered (e.g. via UPNP) or configured we just announce to
each peer the address that peer told us. Since peers could
already replace, forge, or drop our address messages this cannot
create a new vulnerability... but if even one of our peers is
giving us a good address we'll eventually make a useful
advertisement.

Rebased-from: a851bf84f6a2ff95bd86b23e55bb0647f5f47188
Rebased-by: Warren Togami