|
|
|
@ -28,29 +28,27 @@ class Publisher:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
|
|
|
|
|
self.localhostname = split(socket.gethostname(),'.')[0]+'.local.'
|
|
|
|
|
try:
|
|
|
|
|
self.localip = socket.gethostbyname(self.localhostname)
|
|
|
|
|
self.zeroconf = Zeroconf.Zeroconf(self.localip)
|
|
|
|
|
except:
|
|
|
|
|
return
|
|
|
|
|
self.active = True
|
|
|
|
|
try:
|
|
|
|
|
self.localip = socket.gethostbyname(self.localhostname)
|
|
|
|
|
self.zeroconf = Zeroconf.Zeroconf(self.localip)
|
|
|
|
|
except:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self.active = True
|
|
|
|
|
|
|
|
|
|
toRegister = self.services()
|
|
|
|
|
for i in toRegister:
|
|
|
|
|
service = Zeroconf.ServiceInfo(
|
|
|
|
|
i["type"]+".local.",
|
|
|
|
|
i["name"]+"."+i["type"]+".local.",
|
|
|
|
|
socket.inet_aton(self.localip),
|
|
|
|
|
i["port"],
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
i["properties"],
|
|
|
|
|
self.localhostname)
|
|
|
|
|
self.zeroconf.registerService(service)
|
|
|
|
|
i["type"]+".local.",
|
|
|
|
|
i["name"]+"."+i["type"]+".local.",
|
|
|
|
|
socket.inet_aton(self.localip),
|
|
|
|
|
i["port"],
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
i["properties"],
|
|
|
|
|
self.localhostname)
|
|
|
|
|
self.zeroconf.registerService(service)
|
|
|
|
|
|
|
|
|
|
def shutdown(self):
|
|
|
|
|
if self.active: self.zeroconf.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|