d827b4d5af
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>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import platform
|
|
import json
|
|
import subprocess
|
|
import os
|
|
|
|
from urllib2 import urlopen
|
|
from lbryschema import __version__ as lbryschema_version
|
|
from lbryum import __version__ as LBRYUM_VERSION
|
|
from lbrynet import build_type, __version__ as lbrynet_version
|
|
from lbrynet.conf import ROOT_DIR
|
|
|
|
|
|
def get_lbrynet_version():
|
|
if build_type.BUILD == "dev":
|
|
try:
|
|
with open(os.devnull, 'w') as devnull:
|
|
git_dir = ROOT_DIR + '/.git'
|
|
return subprocess.check_output(
|
|
['git', '--git-dir='+git_dir, 'describe', '--dirty', '--always'],
|
|
stderr=devnull
|
|
).strip().lstrip('v')
|
|
except (subprocess.CalledProcessError, OSError):
|
|
print "failed to get version from git"
|
|
return lbrynet_version
|
|
|
|
|
|
def get_platform(get_ip=True):
|
|
p = {
|
|
"processor": platform.processor(),
|
|
"python_version": platform.python_version(),
|
|
"platform": platform.platform(),
|
|
"os_release": platform.release(),
|
|
"os_system": platform.system(),
|
|
"lbrynet_version": get_lbrynet_version(),
|
|
"lbryum_version": LBRYUM_VERSION,
|
|
"lbryschema_version": lbryschema_version,
|
|
"build": build_type.BUILD, # CI server sets this during build step
|
|
}
|
|
|
|
if get_ip:
|
|
try:
|
|
p['ip'] = json.load(urlopen('http://ipv4.jsonip.com'))['ip']
|
|
except:
|
|
p['ip'] = "Could not determine IP"
|
|
|
|
return p
|