0.6.11 doesn't work on ipv4 only hardware
Posted: December 1st, 2011, 1:01 pm
I don't know if anyone has ever tried to run SABnzbd 0.6.11 on hardware that only supports IPv4, but for me it fails because of a number of reasons when trying to attach the web interface to either 'localhost' or '0.0.0.0'. That's because in SABnzbd.py the following happens:
will always return an array with more than 1 element (three times '127.0.0.1' on all of my Debian/Ubuntu test systems)
also always true in the scenario given above and because of line 1302
thus, line 1305/1306 will set hosts[1] to '::1' - and that's where things start to break because on IPv4 only hardware this will raise an exception (protocol not supported). And it even doesn't evaluate the new --stack option, thus setting an IPv6 address even in case the user explicitly disables IPv6 by using '--stack ipv4'.
A non intrusive patch that makes use of the new '--stack' option could look like this:
This would trigger only if forced by using '--stack ipv4' and in that case set hosts[1] to '127.0.0.1' which actually shouldn't be necessary since that's what should be the value already. The second hunk is just to make sure that in case multilocal would really be set to False and https isn't enabled at least some sort of web interface is started.
Feel free to use, modify, ignore or to tell me where my error is ;-)
Code: Select all
line 1302: hosts = all_localhosts()Code: Select all
line 1303: multilocal = len(hosts) > 1 and cherryhost in ('localhost', '0.0.0.0')thus, line 1305/1306 will set hosts[1] to '::1' - and that's where things start to break because on IPv4 only hardware this will raise an exception (protocol not supported). And it even doesn't evaluate the new --stack option, thus setting an IPv6 address even in case the user explicitly disables IPv6 by using '--stack ipv4'.
A non intrusive patch that makes use of the new '--stack' option could look like this:
Code: Select all
--- a/SABnzbd-0.6.11/SABnzbd.py 2011-11-29 21:28:21.000000000 +0100
+++ b/SABnzbd-0.6.11/SABnzbd.py 2011-12-01 18:50:30.393379263 +0100
@@ -1302,13 +1302,16 @@
hosts = all_localhosts()
multilocal = len(hosts) > 1 and cherryhost in ('localhost', '0.0.0.0')
- # For 0.0.0.0 CherryPy will always pick IPv4, so make sure the secondary localhost is IPv6
- if multilocal and cherryhost == '0.0.0.0' and hosts[1] == '127.0.0.1':
- hosts[1] = '::1'
-
- # The Windows binary requires numeric localhost as primary address
- if multilocal and cherryhost == 'localhost' and hosts[1] == '127.0.0.1':
- cherryhost = '::1'
+ if 'ipv6' in (stack) or stack == '':
+ # For 0.0.0.0 CherryPy will always pick IPv4, so make sure the secondary localhost is IPv6
+ if multilocal and cherryhost == '0.0.0.0' and hosts[1] == '127.0.0.1':
+ hosts[1] = '::1'
+
+ # The Windows binary requires numeric localhost as primary address
+ if multilocal and cherryhost == 'localhost' and hosts[1] == '127.0.0.1':
+ cherryhost = '::1'
+ else:
+ hosts[1] = '127.0.0.1'
if enable_https:
if https_port:
@@ -1329,7 +1332,10 @@
elif multilocal:
# Extra HTTP port for secondary localhost
attach_server(hosts[1], cherryport)
-
+ else:
+ # if no https and no multilocal, it would be nice if we'd
+ # attach to at least some port, no?
+ attach_server(cherryhost, cherryport)
if no_login:
sabnzbd.cfg.username.set('')Feel free to use, modify, ignore or to tell me where my error is ;-)