Merge pull request #795 from dz0ny/fix/mdns_resolve
avahi: Service hostname must contain, resolvable fqdn
This commit is contained in:
commit
d2a5271a90
@ -58,10 +58,10 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener):
|
|||||||
if self.zeroconf_name:
|
if self.zeroconf_name:
|
||||||
self.zeroconf_http = zeroconf.Zeroconf(
|
self.zeroconf_http = zeroconf.Zeroconf(
|
||||||
stype='_http._tcp', name=self.zeroconf_name,
|
stype='_http._tcp', name=self.zeroconf_name,
|
||||||
host=self.hostname, port=self.port)
|
port=self.port)
|
||||||
self.zeroconf_mopidy_http = zeroconf.Zeroconf(
|
self.zeroconf_mopidy_http = zeroconf.Zeroconf(
|
||||||
stype='_mopidy-http._tcp', name=self.zeroconf_name,
|
stype='_mopidy-http._tcp', name=self.zeroconf_name,
|
||||||
host=self.hostname, port=self.port)
|
port=self.port)
|
||||||
self.zeroconf_http.publish()
|
self.zeroconf_http.publish()
|
||||||
self.zeroconf_mopidy_http.publish()
|
self.zeroconf_mopidy_http.publish()
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class MpdFrontend(pykka.ThreadingActor, CoreListener):
|
|||||||
if self.zeroconf_name:
|
if self.zeroconf_name:
|
||||||
self.zeroconf_service = zeroconf.Zeroconf(
|
self.zeroconf_service = zeroconf.Zeroconf(
|
||||||
stype='_mpd._tcp', name=self.zeroconf_name,
|
stype='_mpd._tcp', name=self.zeroconf_name,
|
||||||
host=self.hostname, port=self.port)
|
port=self.port)
|
||||||
self.zeroconf_service.publish()
|
self.zeroconf_service.publish()
|
||||||
|
|
||||||
def on_stop(self):
|
def on_stop(self):
|
||||||
|
|||||||
@ -43,21 +43,17 @@ class Zeroconf(object):
|
|||||||
:type text: list of str
|
:type text: list of str
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, port, stype=None, domain=None,
|
def __init__(self, name, port, stype=None, domain=None, text=None):
|
||||||
host=None, text=None):
|
|
||||||
self.group = None
|
self.group = None
|
||||||
self.stype = stype or '_http._tcp'
|
self.stype = stype or '_http._tcp'
|
||||||
self.domain = domain or ''
|
self.domain = domain or ''
|
||||||
self.port = port
|
self.port = port
|
||||||
self.text = text or []
|
self.text = text or []
|
||||||
if host in ('::', '0.0.0.0'):
|
|
||||||
self.host = ''
|
|
||||||
else:
|
|
||||||
self.host = host
|
|
||||||
|
|
||||||
template = string.Template(name)
|
template = string.Template(name)
|
||||||
self.name = template.safe_substitute(
|
self.name = template.safe_substitute(
|
||||||
hostname=self.host or socket.getfqdn(), port=self.port)
|
hostname=socket.getfqdn(), port=self.port)
|
||||||
|
self.host = '%s.local' % socket.getfqdn()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'Zeroconf service %s at [%s]:%d' % (
|
return 'Zeroconf service %s at [%s]:%d' % (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user