Skip to content

How to use zeroconf replace dns-sd #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NullYing opened this issue Jun 7, 2020 · 3 comments
Closed

How to use zeroconf replace dns-sd #275

NullYing opened this issue Jun 7, 2020 · 3 comments

Comments

@NullYing
Copy link

NullYing commented Jun 7, 2020

dns-sd -R "Library Color ddd" _ipp._tcp.,_universal . 631 pdl="image/urf" URF=""

My code

#!/usr/bin/env python3

""" Example of announcing a service (in this case, a fake HTTP server) """

import argparse
import logging
import socket
from time import sleep

from zeroconf import IPVersion, ServiceInfo, Zeroconf

desc = {
    "pdl": "image/urf",
    "URF": "",
}

if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    parser = argparse.ArgumentParser()
    parser.add_argument('--debug', action='store_true')
    version_group = parser.add_mutually_exclusive_group()
    version_group.add_argument('--v6', action='store_true')
    version_group.add_argument('--v6-only', action='store_true')
    args = parser.parse_args()

    if args.debug:
        logging.getLogger('zeroconf').setLevel(logging.DEBUG)
    if args.v6:
        ip_version = IPVersion.All
    elif args.v6_only:
        ip_version = IPVersion.V6Only
    else:
        ip_version = IPVersion.V4Only

    info = ServiceInfo(
        "_ipp._tcp.local.",
        "Library Color ddd._ipp._tcp.local.",
        addresses=[socket.inet_aton("192.168.67.101")],
        port=631,
        properties=desc,
        server="Library Color ddd._ipp._tcp.local.",
        priority=40,
    )

    zeroconf = Zeroconf(ip_version=ip_version)
    print("Registration of a service, press Ctrl-C to exit...")
    zeroconf.register_service(info)
    try:
        while True:
            sleep(0.1)
    except KeyboardInterrupt:
        pass
    finally:
        print("Unregistering...")
        zeroconf.unregister_service(info)
        zeroconf.close()

It's wrong

@jstasiak
Copy link
Collaborator

jstasiak commented Jun 7, 2020

Please provide:

  • Versions of the relevant software (Linux kernel, Avahi, Python, python-zeroconf)
  • The exact way you execute the second script
  • The actual output of the commands
  • The output you expect (if the difference is subtle please point it out)
  • If there's an error please provide a full stack trace

These pieces of information are essential to figuring out what's wrong and possibly fixing it (in this case and any other).

@NullYing
Copy link
Author

NullYing commented Jun 8, 2020

I found the reason,python-zeroconf don't support subtype

@NullYing NullYing closed this as completed Jun 8, 2020
@jstasiak
Copy link
Collaborator

jstasiak commented Jun 8, 2020

I believe it does, there are tests verifying it. Maybe there's something specific you have an issue with, it's not clear without more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants