avahi: Add hostname and port template values to names
This commit is contained in:
parent
fb31193ed0
commit
e9c2816354
@ -100,7 +100,8 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener):
|
||||
host=self.hostname, port=self.port)
|
||||
|
||||
if self.zeroconf_service.publish():
|
||||
logger.info('Registered HTTP with Zeroconf as %s', name)
|
||||
logger.info('Registered HTTP with Zeroconf as "%s"',
|
||||
self.zeroconf_service.name)
|
||||
else:
|
||||
logger.warning('Registering HTTP with Zeroconf failed.')
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ hostname = 127.0.0.1
|
||||
port = 6680
|
||||
static_dir =
|
||||
zeroconf_enabled = true
|
||||
zeroconf_name = Mopidy
|
||||
zeroconf_name = Mopidy HTTP server on $hostname
|
||||
|
||||
[loglevels]
|
||||
cherrypy = warning
|
||||
|
||||
@ -48,7 +48,8 @@ class MpdFrontend(pykka.ThreadingActor, CoreListener):
|
||||
port=self.port, host=self.hostname)
|
||||
|
||||
if self.zeroconf_service.publish():
|
||||
logger.info('Registered MPD with Zeroconf as %s', name)
|
||||
logger.info('Registered MPD with Zeroconf as "%s"',
|
||||
self.zeroconf_service.name)
|
||||
else:
|
||||
logger.warning('Registering MPD with Zeroconf failed.')
|
||||
|
||||
|
||||
@ -6,4 +6,4 @@ password =
|
||||
max_connections = 20
|
||||
connection_timeout = 60
|
||||
zeroconf_enabled = true
|
||||
zeroconf_name = Mopidy (MPD)
|
||||
zeroconf_name = Mopidy MPD server on $hostname
|
||||
|
||||
@ -2,6 +2,8 @@ from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import re
|
||||
import socket
|
||||
import string
|
||||
|
||||
logger = logging.getLogger('mopidy.utils.zerconf')
|
||||
|
||||
@ -31,13 +33,16 @@ class Zeroconf:
|
||||
|
||||
def __init__(self, name, port, stype="_http._tcp",
|
||||
domain="", host="", text=[]):
|
||||
self.name = name
|
||||
self.group = None
|
||||
self.stype = stype
|
||||
self.domain = domain
|
||||
self.port = port
|
||||
self.text = text
|
||||
self.host = _filter_loopback_and_meta_addresses(host)
|
||||
self.group = None
|
||||
|
||||
template = string.Template(name)
|
||||
self.name = template.safe_substitute(
|
||||
hostname=self.host or socket.getfqdn(), port=self.port)
|
||||
|
||||
def publish(self):
|
||||
if not dbus:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user