Skip to content

Commit 7d9e044

Browse files
committed
chore: failed to smooth out interface suffix like %en8
1 parent 15c1264 commit 7d9e044

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

tests/perceptor-host-test/python/server.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66
import time
77
from aiohttp import web, WSMsgType
8-
from zeroconf import Zeroconf, ServiceInfo
8+
from zeroconf import Zeroconf, ServiceInfo, IPVersion
99
import netifaces
1010
import socket
1111

@@ -309,22 +309,19 @@ async def root_handler(request):
309309
else:
310310
print("SSL keys not found, using HTTP")
311311

312+
# Need real IP
313+
local_ip = socket.gethostbyname(socket.gethostname()).split('%')[0]
314+
312315
# Start Zeroconf
313-
zeroconf = Zeroconf()
316+
zeroconf = Zeroconf(ip_version=IPVersion.V4Only)
314317
try:
315-
# Need real IP
316-
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
317-
s.connect(("8.8.8.8", 80))
318-
local_ip = s.getsockname()[0]
319-
s.close()
320-
321318
info = ServiceInfo(
322319
"_allspark._tcp.local.",
323320
f"{config['serviceName']}._allspark._tcp.local.",
324321
addresses=[socket.inet_aton(local_ip)],
325322
port=config['port'],
326-
properties={'path': '/'},
327-
server=f"{socket.gethostname()}.local."
323+
properties={},
324+
server=f"{local_ip}.local."
328325
)
329326
zeroconf.register_service(info)
330327
print(f"Advertising Bonjour service: {config['serviceName']} on {local_ip}:{config['port']}")

0 commit comments

Comments
 (0)