I've now implemented the check for "listening on LAN'. See patch and resulting logging below
To be done (I guess): first check for "listening on LAN", and after that starting the "import pybonjour"
Feedback very welcome.
Code: Select all
# Wait for server to become ready
cherrypy.engine.wait(cherrypy.process.wspbus.states.STARTED)
####Start Bonjour Zeroconf patch########################################################
try:
from sabnzbd.utils import pybonjour
logging.info('Zeroconf service succesfully imported')
except OSError:
logging.info('Zeroconf service could not be registered')
else:
logging.info('cherryhost is ' + cherryhost)
if cherryhost == '0.0.0.0' or cherryhost in ('::','[::]'):
logging.info('SABnzbd is configured to listen on LAN interface, so start Bonjour Zeroconf')
from socket import gethostname
def zeroconf_callback(sdRef, flags, errorCode, name, regtype, domain):
if errorCode == pybonjour.kDNSServiceErr_NoError:
logging.info('Registering Zeroconf service')
zeroconf_sdRef = pybonjour.DNSServiceRegister(
name = "SABnzbd on " + gethostname() ,
regtype = '_http._tcp',
# error port = int(cfg['misc']['port']),
# OK port = int(8080),
port = int(cherryport),
txtRecord = pybonjour.TXTRecord({'path': '/sabnzbd/'}),
callBack = zeroconf_callback)
pybonjour.DNSServiceProcessResult(zeroconf_sdRef)
else:
logging.info('SABnzbd is not configured to listen on a LAN interface, so not starting Bonjour Zeroconf')
####End Bonjour Zeroconf patch##########################################################
if enable_https and https_port:
launch_a_browser("https://%s:%s/sabnzbd" % (browserhost, https_port))
else:
launch_a_browser("http://%s:%s/sabnzbd" % (browserhost, cherryport))
Output with host=[::] (or 0.0.0.0)
Code: Select all
2009-06-16 20:40:07,475::INFO::[_cplogging:55] [16/Jun/2009:20:40:07] ENGINE Bus STARTED
2009-06-16 20:40:07,499::INFO::[SABnzbd:1119] Zeroconf service succesfully imported
2009-06-16 20:40:07,499::INFO::[SABnzbd:1125] cherryhost is ::
2009-06-16 20:40:07,500::INFO::[SABnzbd:1127] SABnzbd is configured to listen on LAN interface, so start Bonjour Zeroconf
2009-06-16 20:40:07,507::INFO::[misc:425] Lauching browser with http://localhost:8080/sabnzbd
Output with host=localhost:
Code: Select all
2009-06-16 20:41:03,155::INFO::[_cplogging:55] [16/Jun/2009:20:41:03] ENGINE Bus STARTED
2009-06-16 20:41:03,190::INFO::[SABnzbd:1119] Zeroconf service succesfully imported
2009-06-16 20:41:03,191::INFO::[SABnzbd:1125] cherryhost is localhost
2009-06-16 20:41:03,191::INFO::[SABnzbd:1146] SABnzbd is not configured to listen on a LAN interface, so not starting Bonjour Zeroconf
2009-06-16 20:41:03,192::INFO::[misc:425] Lauching browser with http://localhost:8080/sabnzbd
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate