Fix multicast dns issue
This commit is contained in:
parent
1dd7816590
commit
536dd4a2b5
|
@ -71,8 +71,8 @@ class ZeroconfServer(Closeable):
|
|||
"CPath": "/",
|
||||
"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 +81,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:
|
||||
|
@ -191,6 +198,7 @@ class ZeroconfServer(Closeable):
|
|||
def run(self):
|
||||
while not self.__should_stop:
|
||||
__socket, address = self.__socket.accept()
|
||||
print("Received request!")
|
||||
|
||||
def anonymous():
|
||||
self.__handle(__socket)
|
||||
|
|
Loading…
Reference in New Issue