Skip to content

Commit 4da1612

Browse files
vazhnovjstasiak
authored andcommitted
Restore IPv6 addresses output
Before this change, script `examples/browser.py` printed IPv4 only, even with `--v6` argument. With this change, `examples/browser.py` prints both IPv4 + IPv6 by default, and IPv6 only with `--v6-only` argument. I took the idea from the fork https://github.com/ad3angel1s/python-zeroconf/blob/master/examples/browser.py
1 parent 4744427 commit 4da1612

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

examples/browser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import argparse
99
import logging
10-
import socket
1110
from time import sleep
1211
from typing import cast
1312

@@ -23,7 +22,7 @@ def on_service_state_change(
2322
info = zeroconf.get_service_info(service_type, name)
2423
print("Info from zeroconf.get_service_info: %r" % (info))
2524
if info:
26-
addresses = ["%s:%d" % (socket.inet_ntoa(addr), cast(int, info.port)) for addr in info.addresses]
25+
addresses = ["%s:%d" % (addr, cast(int, info.port)) for addr in info.parsed_addresses()]
2726
print(" Addresses: %s" % ", ".join(addresses))
2827
print(" Weight: %d, priority: %d" % (info.weight, info.priority))
2928
print(" Server: %s" % (info.server,))

0 commit comments

Comments
 (0)