Fix mDNS issue

This commit is contained in:
kokarare1212 2021-09-14 07:11:41 +09:00
parent 15d8721167
commit 99ffe99e82
No known key found for this signature in database
GPG Key ID: 9FB32C7C7D874F7A
1 changed files with 9 additions and 1 deletions

View File

@ -72,7 +72,8 @@ class ZeroconfServer(Closeable):
"VERSION": "1.0",
"STACK": "SP",
},
inner.device_name,
self.get_useful_hostname() + ".",
addresses=[socket.inet_aton(socket.gethostbyname(self.get_useful_hostname()))]
)
self.__zeroconf.register_service(self.__service_info)
threading.Thread(target=self.__zeroconf.start, name="zeroconf-multicast-dns-server").start()
@ -81,6 +82,13 @@ class ZeroconfServer(Closeable):
self.__zeroconf.close()
self.__runner.close()
def get_useful_hostname(self) -> str:
host = socket.gethostname()
if host == "localhost":
pass
else:
return host
def handle_add_user(self, __socket: socket.socket, params: dict[str, str], http_version: str) -> None:
username = params.get("userName")
if not username: