Skip to main content

A pure python implementation of multicast DNS service discovery

Project description

python-zeroconf

https://github.com/python-zeroconf/python-zeroconf/workflows/CI/badge.svg https://img.shields.io/pypi/v/zeroconf.svg https://codecov.io/gh/python-zeroconf/python-zeroconf/branch/master/graph/badge.svg Codspeed.io status for python-zeroconf Documentation Status

Documentation.

This is fork of pyzeroconf, Multicast DNS Service Discovery for Python, originally by Paul Scott-Murphy (https://github.com/paulsm/pyzeroconf), modified by William McBrine (https://github.com/wmcbrine/pyzeroconf).

The original William McBrine’s fork note:

This fork is used in all of my TiVo-related projects: HME for Python
(and therefore HME/VLC), Network Remote, Remote Proxy, and pyTivo.
Before this, I was tracking the changes for zeroconf.py in three
separate repos. I figured I should have an authoritative source.

Although I make changes based on my experience with TiVos, I expect that
they're generally applicable. This version also includes patches found
on the now-defunct (?) Launchpad repo of pyzeroconf, and elsewhere
around the net -- not always well-documented, sorry.

Compatible with:

  • Bonjour

  • Avahi

Compared to some other Zeroconf/Bonjour/Avahi Python packages, python-zeroconf:

  • isn’t tied to Bonjour or Avahi

  • doesn’t use D-Bus

  • doesn’t force you to use particular event loop or Twisted (asyncio is used under the hood but not required)

  • is pip-installable

  • has PyPI distribution

  • has an optional cython extension for performance (pure python is supported as well)

Python compatibility

  • CPython 3.9+

  • PyPy 3.9+

Versioning

This project uses semantic versioning.

Status

This project is actively maintained.

Traffic Reduction

Before version 0.32, most traffic reduction techniques described in https://datatracker.ietf.org/doc/html/rfc6762#section-7 where not implemented which could lead to excessive network traffic. It is highly recommended that version 0.32 or later is used if this is a concern.

IPv6 support

IPv6 support is relatively new and currently limited, specifically:

  • InterfaceChoice.All is an alias for InterfaceChoice.Default on non-POSIX systems.

  • Dual-stack IPv6 sockets are used, which may not be supported everywhere (some BSD variants do not have them).

  • Listening on localhost (::1) does not work. Help with understanding why is appreciated.

How to get python-zeroconf?

The easiest way to install python-zeroconf is using pip:

pip install zeroconf

How do I use it?

Here’s an example of browsing for a service:

from zeroconf import ServiceBrowser, ServiceListener, Zeroconf


class MyListener(ServiceListener):

    def update_service(self, zc: Zeroconf, type_: str, name: str) -> None:
        print(f"Service {name} updated")

    def remove_service(self, zc: Zeroconf, type_: str, name: str) -> None:
        print(f"Service {name} removed")

    def add_service(self, zc: Zeroconf, type_: str, name: str) -> None:
        info = zc.get_service_info(type_, name)
        print(f"Service {name} added, service info: {info}")


zeroconf = Zeroconf()
listener = MyListener()
browser = ServiceBrowser(zeroconf, "_http._tcp.local.", listener)
try:
    input("Press enter to exit...\n\n")
finally:
    zeroconf.close()

If you don’t know the name of the service you need to browse for, try:

from zeroconf import ZeroconfServiceTypes
print('\n'.join(ZeroconfServiceTypes.find()))

See examples directory for more.

Changelog

Changelog

License

LGPL, see COPYING file for details.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zeroconf-0.147.4.tar.gz (166.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zeroconf-0.147.4-cp314-cp314-manylinux_2_41_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.41+ x86-64

File details

Details for the file zeroconf-0.147.4.tar.gz.

File metadata

  • Download URL: zeroconf-0.147.4.tar.gz
  • Upload date:
  • Size: 166.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for zeroconf-0.147.4.tar.gz
Algorithm Hash digest
SHA256 e108b9e2f39e39e363908175c2bf25a0f421f1ce7a67d446cf64d6d3590f7379
MD5 0e7b87b408ffc32e8dd865934512d61a
BLAKE2b-256 4505fd76ae1da8348408efd33ace63d4fdc734b252b2b70f02550684245d71c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for zeroconf-0.147.4.tar.gz:

Publisher: ci.yml on python-zeroconf/python-zeroconf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zeroconf-0.147.4-cp314-cp314-manylinux_2_41_x86_64.whl.

File metadata

File hashes

Hashes for zeroconf-0.147.4-cp314-cp314-manylinux_2_41_x86_64.whl
Algorithm Hash digest
SHA256 f58990d3895f740bcf2a70dcfbe15648027ab50866efd82a800a80634c9799ab
MD5 50a82d5184b3f6fc4fe1236946dfcd1e
BLAKE2b-256 13690189c07d63c95da2b48e5ee9639abf845da4057264d3a38b885402072ced

See more details on using hashes here.

Provenance

The following attestation bundles were made for zeroconf-0.147.4-cp314-cp314-manylinux_2_41_x86_64.whl:

Publisher: ci.yml on python-zeroconf/python-zeroconf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page