platform ip: ensure daemon retrieves IPv4 address only

When contacting jsonip.com to retrieve the node external IP,
the connection might be established with IPv6 and thus return
an address belonging to that family.

This address is then used to initialize the external_ip member of
Daemon session, but unfortunately IPv6 is not yet handled well.

Using an IPv6 as external IP is currently breaking parts of the
Daemon resulting in no peer connectivity at all.

We should stick to IPv4 for time being.

http://jsonip.com/about says "ipv4-only":"https://ipv4.jsonip.com"

therefore, change the IP retrieval URL to ipv4.jsonip.com to
make sure the connection is established only using an IPv4 address.

Closes: https://github.com/lbryio/lbry/issues/971
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
This commit is contained in:
Antonio Quartulli 2017-10-31 10:26:26 +08:00 committed by Alex Grintsvayg
parent db751eabb6
commit d827b4d5af
2 changed files with 2 additions and 1 deletions

View file

@ -14,6 +14,7 @@ at anytime.
### Fixed
* Fixed amount of close nodes to add to list in case of extension to neighbouring k-buckets
* Fixed external IP detection via jsonip.com (avoid detecting IPv6)
*
### Deprecated

View file

@ -39,7 +39,7 @@ def get_platform(get_ip=True):
if get_ip:
try:
p['ip'] = json.load(urlopen('http://jsonip.com'))['ip']
p['ip'] = json.load(urlopen('http://ipv4.jsonip.com'))['ip']
except:
p['ip'] = "Could not determine IP"