Skip to content

Commit

Permalink
updated zeroconf address
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick762 committed Jun 16, 2023
1 parent fb720e6 commit 5236fbf
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion streamdeckapi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,30 @@ def cancel(self):
self._task.cancel()


def get_local_ip():
"""Get local ip address."""
connection = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
connection.connect(("192.255.255.255", 1))
address = connection.getsockname()[0]
except socket.error:
address = "127.0.0.1"
finally:
connection.close()
return address


def start_zeroconf():
"""Start Zeroconf server."""

host = get_local_ip()

print("Using host", host, "for Zeroconf")

info = ServiceInfo(
SD_ZEROCONF,
f"Stream Deck API Server.{SD_ZEROCONF}",
addresses=[socket.inet_aton("127.0.0.1")],
addresses=[socket.inet_aton(host)],
port=PLUGIN_PORT,
properties={'path': '/sd/info'},
server="pythonserver.local.",
Expand Down

0 comments on commit 5236fbf

Please sign in to comment.