fix checking the external ip

This commit is contained in:
Jack Robison 2018-01-22 15:47:14 -05:00
parent a6588f740a
commit eb4ba089ab
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF

View file

@ -3,7 +3,7 @@ import json
import subprocess
import os
from urllib2 import urlopen
from urllib2 import urlopen, URLError
from lbryschema import __version__ as lbryschema_version
from lbryum import __version__ as LBRYUM_VERSION
from lbrynet import build_type, __version__ as lbrynet_version
@ -37,10 +37,14 @@ def get_platform(get_ip=True):
"build": build_type.BUILD, # CI server sets this during build step
}
# TODO: remove this from get_platform and add a get_external_ip function using txrequests
if get_ip:
try:
p['ip'] = json.load(urlopen('http://ipv4.jsonip.com'))['ip']
except:
response = json.loads(urlopen("https://api.lbry.io/ip").read())
if not response['success']:
raise URLError("failed to get external ip")
p['ip'] = response['data']['ip']
except (URLError, AssertionError):
p['ip'] = "Could not determine IP"
return p