mirror of
https://github.com/sabnzbd/sabnzbd.git
synced 2025-12-24 08:08:37 -05:00
Use self-test.sabnzbd.org for connection tests
This commit is contained in:
@@ -1158,11 +1158,11 @@ def proxy_pre_queue(name, pp, cat, script, priority, size, groups):
|
||||
|
||||
def test_ipv6():
|
||||
""" Check if external IPv6 addresses are reachable """
|
||||
if not cfg.ipv6_test_host():
|
||||
if not cfg.selftest_host():
|
||||
# User disabled the test, assume active IPv6
|
||||
return True
|
||||
try:
|
||||
info = socket.getaddrinfo(cfg.ipv6_test_host(), 443, socket.AF_INET6, socket.SOCK_STREAM, socket.IPPROTO_IP, socket.AI_CANONNAME)
|
||||
info = socket.getaddrinfo(cfg.selftest_host(), 443, socket.AF_INET6, socket.SOCK_STREAM, socket.IPPROTO_IP, socket.AI_CANONNAME)
|
||||
except:
|
||||
logging.debug("Test IPv6: Disabling IPv6, because it looks like it's not available. Reason: %s", sys.exc_info()[0] )
|
||||
return False
|
||||
|
||||
@@ -83,7 +83,7 @@ pre_script = OptionStr('misc', 'pre_script', 'None')
|
||||
script_can_fail = OptionBool('misc', 'script_can_fail', False)
|
||||
start_paused = OptionBool('misc', 'start_paused', False)
|
||||
enable_https_verification = OptionBool('misc', 'enable_https_verification', True)
|
||||
ipv6_test_host = OptionStr('misc', 'ipv6_test_host', 'test-ipv6.sabnzbd.org')
|
||||
selftest_host = OptionStr('misc', 'selftest_host', 'self-test.sabnzbd.org')
|
||||
|
||||
enable_unrar = OptionBool('misc', 'enable_unrar', True)
|
||||
enable_unzip = OptionBool('misc', 'enable_unzip', True)
|
||||
|
||||
@@ -27,6 +27,7 @@ import urllib
|
||||
import json
|
||||
import re
|
||||
import hashlib
|
||||
import socket
|
||||
from random import randint
|
||||
from xml.sax.saxutils import escape
|
||||
|
||||
@@ -1504,7 +1505,7 @@ SPECIAL_BOOL_LIST = \
|
||||
SPECIAL_VALUE_LIST = \
|
||||
('size_limit', 'folder_max_length', 'fsys_type', 'movie_rename_limit', 'nomedia_marker',
|
||||
'req_completion_rate', 'wait_ext_drive', 'history_limit', 'show_sysload', 'ipv6_servers',
|
||||
'rating_host', 'ipv6_test_host'
|
||||
'rating_host', 'selftest_host'
|
||||
)
|
||||
SPECIAL_LIST_LIST = \
|
||||
('rss_odd_titles', 'prio_sort_list'
|
||||
@@ -2577,14 +2578,12 @@ class Status(object):
|
||||
|
||||
# Dashboard: Begin
|
||||
if not kwargs.get('skip_dashboard'):
|
||||
from sabnzbd.utils.getipaddress import localipv4, publicipv4, ipv6
|
||||
header['localipv4'] = localipv4()
|
||||
header['publicipv4'] = publicipv4()
|
||||
header['ipv6'] = ipv6()
|
||||
# Dashboard: DNS-check
|
||||
try:
|
||||
import socket
|
||||
socket.gethostbyname('www.google.com')
|
||||
socket.gethostbyname(cfg.selftest_host())
|
||||
header['dnslookup'] = "OK"
|
||||
except:
|
||||
header['dnslookup'] = None
|
||||
@@ -3065,7 +3064,6 @@ def rss_history(url, limit=50, search=None):
|
||||
|
||||
return rss.write()
|
||||
|
||||
|
||||
def rss_warnings():
|
||||
""" Return an RSS feed with last warnings/errors """
|
||||
rss = RSS()
|
||||
@@ -3082,3 +3080,36 @@ def rss_warnings():
|
||||
rss.channel.lastBuildDate = std_time(time.time())
|
||||
rss.channel.pubDate = rss.channel.lastBuildDate
|
||||
return rss.write()
|
||||
|
||||
def localipv4():
|
||||
try:
|
||||
s_ipv4 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s_ipv4.connect(('1.2.3.4', 80)) # Option: use 100.64.1.1 (IANA-Reserved IPv4 Prefix for Shared Address Space)
|
||||
ipv4 = s_ipv4.getsockname()[0]
|
||||
s_ipv4.close()
|
||||
except:
|
||||
ipv4 = None
|
||||
pass
|
||||
return ipv4
|
||||
|
||||
def publicipv4():
|
||||
try:
|
||||
import urllib2
|
||||
req = urllib2.Request("http://" + cfg.selftest_host(), headers={'User-Agent': 'SABnzbd+/%s' % sabnzbd.version.__version__})
|
||||
f = urllib2.urlopen(req, timeout=2) # timeout 2 seconds, in case website is not accessible
|
||||
public_ipv4 = f.read()
|
||||
socket.inet_aton(public_ipv4) # if we got anything else than a plain IPv4 address, this will raise an exception
|
||||
except:
|
||||
public_ipv4 = None
|
||||
pass
|
||||
return public_ipv4
|
||||
|
||||
def ipv6():
|
||||
try:
|
||||
s_ipv6 = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
||||
s_ipv6.connect(('2001:db8::8080', 80)) # IPv6 prefix for documentation purpose
|
||||
ipv6 = s_ipv6.getsockname()[0]
|
||||
s_ipv6.close()
|
||||
except:
|
||||
ipv6 = None
|
||||
return ipv6
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/python -OO
|
||||
|
||||
import socket
|
||||
|
||||
|
||||
def localipv4():
|
||||
try:
|
||||
s_ipv4 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s_ipv4.connect(('1.2.3.4', 80)) # Option: use 100.64.1.1 (IANA-Reserved IPv4 Prefix for Shared Address Space)
|
||||
ipv4 = s_ipv4.getsockname()[0]
|
||||
s_ipv4.close()
|
||||
except:
|
||||
ipv4 = None
|
||||
pass
|
||||
return ipv4
|
||||
|
||||
|
||||
def publicipv4():
|
||||
try:
|
||||
import urllib2
|
||||
f = urllib2.urlopen("http://api.ipify.org", timeout=2) # timeout 2 seconds, in case website is not accessible
|
||||
public_ipv4 = f.read()
|
||||
socket.inet_aton(public_ipv4) # if we got anything else than a plain IPv4 address, this will raise an exception
|
||||
except:
|
||||
public_ipv4 = None
|
||||
pass
|
||||
return public_ipv4
|
||||
|
||||
|
||||
def ipv6():
|
||||
try:
|
||||
s_ipv6 = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
||||
s_ipv6.connect(('2001:db8::8080', 80)) # IPv6 prefix for documentation purpose
|
||||
ipv6 = s_ipv6.getsockname()[0]
|
||||
s_ipv6.close()
|
||||
except:
|
||||
ipv6 = None
|
||||
return ipv6
|
||||
|
||||
if __name__ == '__main__':
|
||||
print localipv4()
|
||||
print publicipv4()
|
||||
print ipv6()
|
||||
Reference in New Issue
Block a user