Pythonskripte für mDNS und uninstall hinzugefügt
This commit is contained in:
Executable
+34
@@ -0,0 +1,34 @@
|
||||
from zeroconf import Zeroconf, ServiceBrowser
|
||||
|
||||
SERVICE = "_myapp._tcp.local."
|
||||
|
||||
class Listener:
|
||||
def __init__(self, zc: Zeroconf):
|
||||
self.zc = zc
|
||||
|
||||
def add_service(self, zc, type_, name):
|
||||
print("ADD ", name)
|
||||
info = zc.get_service_info(type_, name, timeout=3000)
|
||||
if info:
|
||||
addrs = [ "%d.%d.%d.%d" % tuple(a) for a in info.addresses ]
|
||||
print(" Host: ", info.server)
|
||||
print(" IPs: ", addrs)
|
||||
print(" Port: ", info.port)
|
||||
# TXT-Records
|
||||
props = { k.decode(): v.decode() for k, v in info.properties.items() }
|
||||
print(" TXT: ", props)
|
||||
else:
|
||||
print(" (keine Details auflösbar)")
|
||||
|
||||
def remove_service(self, zc, type_, name):
|
||||
print("REM ", name)
|
||||
|
||||
def update_service(self, zc, type_, name):
|
||||
print("UPD ", name)
|
||||
|
||||
zc = Zeroconf()
|
||||
try:
|
||||
ServiceBrowser(zc, SERVICE, Listener(zc))
|
||||
input("Browsing… Enter zum Beenden\n")
|
||||
finally:
|
||||
zc.close()
|
||||
Reference in New Issue
Block a user