fix _device-info._tcp
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=DNS-SD Proxy
|
||||||
|
After=network.target network.service
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/python3 /home/sysadmin/dns-sd-proxy/proxy.py mdns.home.kuron-germany.de 35353
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
Type=simple
|
||||||
|
User=sysadmin
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from zeroconf import Zeroconf, ServiceBrowser, ServiceStateChange, DNSQuestion, DNSOutgoing, RecordUpdateListener, _TYPE_A, _CLASS_IN, _FLAGS_QR_QUERY
|
from zeroconf import Zeroconf, ServiceBrowser, ServiceStateChange, ServiceInfo, DNSQuestion, DNSOutgoing, RecordUpdateListener, _TYPE_A, _CLASS_IN, _FLAGS_QR_QUERY
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from twisted.internet import reactor, defer, threads
|
from twisted.internet import reactor, defer, threads
|
||||||
@@ -47,9 +47,15 @@ class DynamicResolver(object):
|
|||||||
return answers, [], []
|
return answers, [], []
|
||||||
|
|
||||||
def txt(localname):
|
def txt(localname):
|
||||||
info = self.zeroconf.get_service_info(localname, localname)
|
if localname.endswith('._device-info._tcp.local.'):
|
||||||
if info is None:
|
info = ServiceInfo(localname, localname)
|
||||||
return [], [], []
|
info.request(self.zeroconf, timeout*1000)
|
||||||
|
if not info.text:
|
||||||
|
return [], [], []
|
||||||
|
else:
|
||||||
|
info = self.zeroconf.get_service_info(localname, localname, timeout*1000)
|
||||||
|
if info is None:
|
||||||
|
return [], [], []
|
||||||
|
|
||||||
data = [b"%s=%s" % (p, info.properties[p]) for p in info.properties]
|
data = [b"%s=%s" % (p, info.properties[p]) for p in info.properties]
|
||||||
answers = [dns.RRHeader(name=query.name.name, ttl=ttl, type=dns.TXT, payload=dns.Record_TXT(
|
answers = [dns.RRHeader(name=query.name.name, ttl=ttl, type=dns.TXT, payload=dns.Record_TXT(
|
||||||
@@ -58,7 +64,7 @@ class DynamicResolver(object):
|
|||||||
return answers, [], []
|
return answers, [], []
|
||||||
|
|
||||||
def srv(localname):
|
def srv(localname):
|
||||||
info = self.zeroconf.get_service_info(localname, localname)
|
info = self.zeroconf.get_service_info(localname, localname, timeout*1000)
|
||||||
if info is None:
|
if info is None:
|
||||||
return [], [], []
|
return [], [], []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user