Skip to content

Commit

Permalink
Restore IPv6 addresses output
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vazhnov authored and jstasiak committed Oct 19, 2020
1 parent 4744427 commit 4da1612
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions examples/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import argparse
import logging
import socket
from time import sleep
from typing import cast

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

0 comments on commit 4da1612

Please sign in to comment.