Skip to content

Commit

Permalink
Simplified service constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
jtc42 committed May 8, 2020
1 parent 038855a commit 6b0d372
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/labthings/server/wsgi/gevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def __init__(

def register_zeroconf(self):
if self.labthing:
# Get list of host addresses
mdns_addresses = {
socket.inet_aton(i)
for i in get_all_addresses()
if i not in ("127.0.0.1", "0.0.0.0")
}
# LabThing service
self.service_infos.add(
ServiceInfo(
Expand All @@ -56,11 +62,7 @@ def register_zeroconf(self):
"description": self.labthing.description,
"types": ";".join(self.labthing.types),
},
addresses={
socket.inet_aton(i)
for i in get_all_addresses()
if i not in ("127.0.0.1", "0.0.0.0")
},
addresses=mdns_addresses,
)
)
# Mozilla WebThing service
Expand All @@ -70,11 +72,7 @@ def register_zeroconf(self):
f"{self.labthing.safe_title}._webthing._tcp.local.",
port=self.port,
properties={"path": self.labthing.url_prefix},
addresses={
socket.inet_aton(i)
for i in get_all_addresses()
if i not in ("127.0.0.1", "0.0.0.0")
},
addresses=mdns_addresses,
)
)
self.zeroconf_server = Zeroconf(ip_version=IPVersion.V4Only)
Expand Down

0 comments on commit 6b0d372

Please sign in to comment.