mirror of
https://github.com/sabnzbd/sabnzbd.git
synced 2025-12-27 17:49:20 -05:00
Disable listening on IPv6 addresses by the internal web server.
Setting Config->Special->ipv6_hosting to 1 will enable IPv6 listening. Command line option --ipv6_hosting allows forcing the choice, should SABnzbd not start. Closes #492
This commit is contained in:
18
SABnzbd.py
18
SABnzbd.py
@@ -278,7 +278,7 @@ def print_help():
|
||||
print " --log-all Log all article handling (for developers)"
|
||||
print " --console Force console logging for OSX app"
|
||||
print " --new Run a new instance of SABnzbd"
|
||||
print " --no_ipv6 Do not listen on IPv6 address [::1]"
|
||||
print " --ipv6_hosting <0|1> Listen on IPv6 address [::1]"
|
||||
|
||||
|
||||
def print_version():
|
||||
@@ -699,7 +699,7 @@ def get_webhost(cherryhost, cherryport, https_port):
|
||||
|
||||
def attach_server(host, port, cert=None, key=None, chain=None):
|
||||
""" Define and attach server, optionally HTTPS """
|
||||
if not (sabnzbd.cfg.no_ipv6() and '::1' in host):
|
||||
if sabnzbd.cfg.ipv6_hosting() or '::1' in host:
|
||||
http_server = _cpwsgi_server.CPWSGIServer()
|
||||
http_server.bind_addr = (host, port)
|
||||
if cert and key:
|
||||
@@ -832,7 +832,7 @@ def commandline_handler(frozen=True):
|
||||
try:
|
||||
opts, args = getopt.getopt(info, "phdvncw:l:s:f:t:b:2:",
|
||||
['pause', 'help', 'daemon', 'nobrowser', 'clean', 'logging=',
|
||||
'weblogging=', 'server=', 'templates', 'no_ipv6',
|
||||
'weblogging=', 'server=', 'templates', 'ipv6_hosting=',
|
||||
'template2', 'browser=', 'config-file=', 'force',
|
||||
'version', 'https=', 'autorestarted', 'repair', 'repair-all',
|
||||
'log-all', 'no-login', 'pid=', 'new', 'sessions', 'console', 'pidfile=',
|
||||
@@ -910,7 +910,7 @@ def main():
|
||||
new_instance = False
|
||||
force_sessions = False
|
||||
osx_console = False
|
||||
no_ipv6 = False
|
||||
ipv6_hosting = None
|
||||
|
||||
_service, sab_opts, _serv_opts, upload_nzbs = commandline_handler()
|
||||
|
||||
@@ -1001,9 +1001,9 @@ def main():
|
||||
elif opt in ('--console',):
|
||||
re_argv.append(opt)
|
||||
osx_console = True
|
||||
elif opt in ('--no_ipv6',):
|
||||
no_ipv6 = True
|
||||
|
||||
elif opt in ('--ipv6_hosting',):
|
||||
ipv6_hosting = arg
|
||||
|
||||
sabnzbd.MY_FULLNAME = os.path.normpath(os.path.abspath(sabnzbd.MY_FULLNAME))
|
||||
sabnzbd.MY_NAME = os.path.basename(sabnzbd.MY_FULLNAME)
|
||||
sabnzbd.DIR_PROG = os.path.dirname(sabnzbd.MY_FULLNAME)
|
||||
@@ -1080,8 +1080,8 @@ def main():
|
||||
# Set root folders for HTTPS server file paths
|
||||
sabnzbd.cfg.set_root_folders2()
|
||||
|
||||
if no_ipv6:
|
||||
sabnzbd.cfg.no_ipv6.set(True)
|
||||
if ipv6_hosting is not None:
|
||||
sabnzbd.cfg.ipv6_hosting.set(ipv6_hosting)
|
||||
|
||||
# Determine web host address
|
||||
cherryhost, cherryport, browserhost, https_port = get_webhost(cherryhost, cherryport, https_port)
|
||||
|
||||
@@ -257,7 +257,7 @@ inet_exposure = OptionNumber('misc', 'inet_exposure', 0, protect=True) # 0=loca
|
||||
max_art_tries = OptionNumber('misc', 'max_art_tries', 3, 2)
|
||||
max_art_opt = OptionBool('misc', 'max_art_opt', False)
|
||||
use_pickle = OptionBool('misc', 'use_pickle', False)
|
||||
no_ipv6 = OptionBool('misc', 'no_ipv6', False)
|
||||
ipv6_hosting = OptionBool('misc', 'ipv6_hosting', False)
|
||||
|
||||
# [ncenter]
|
||||
ncenter_enable = OptionBool('ncenter', 'ncenter_enable', sabnzbd.DARWIN_VERSION > 7)
|
||||
|
||||
@@ -1394,7 +1394,7 @@ SPECIAL_BOOL_LIST = \
|
||||
'queue_complete_pers', 'api_warnings', 'allow_64bit_tools',
|
||||
'never_repair', 'allow_streaming', 'ignore_unrar_dates', 'rss_filenames',
|
||||
'osx_menu', 'osx_speed', 'win_menu', 'use_pickle', 'allow_incomplete_nzb',
|
||||
'no_ipv6', 'keep_awake', 'empty_postproc',
|
||||
'ipv6_hosting', 'keep_awake', 'empty_postproc',
|
||||
'web_watchdog', 'wait_for_dfolder', 'warn_empty_nzb', 'enable_bonjour',
|
||||
'warn_dupl_jobs', 'backup_for_duplicates', 'enable_par_cleanup',
|
||||
'enable_https_verification', 'api_logging'
|
||||
|
||||
@@ -265,6 +265,8 @@ def launch_a_browser(url, force=False):
|
||||
# Must use https, because http is not available
|
||||
url = url.replace('http:', 'https:')
|
||||
|
||||
if 'localhost' in url and not cfg.ipv6_hosting():
|
||||
url = url.replace('localhost', '127.0.0.1')
|
||||
logging.info("Launching browser with %s", url)
|
||||
try:
|
||||
if url and not url.startswith('http'):
|
||||
|
||||
Reference in New Issue
Block a user