Git Product home page Git Product logo

mdns's People

Contributors

svinota avatar titilambert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mdns's Issues

Utf-8 error

I get this error when get Pidgin change the status (python 3.4.0 on sailfish OS)

  File "./embedded_libs/mdns/zeroconf.py", line 1138, in run
    self.readers[socket].handle_read()
  File "./embedded_libs/mdns/zeroconf.py", line 1185, in handle_read
    msg = DNSIncoming(data)
  File "./embedded_libs/mdns/zeroconf.py", line 691, in __init__
    self.read_others()
  File "./embedded_libs/mdns/zeroconf.py", line 774, in read_others
    self.read_name())
  File "./embedded_libs/mdns/zeroconf.py", line 842, in read_name
    result = ''.join((result, self.read_utf(off, len) + '.'))
  File "./embedded_libs/mdns/zeroconf.py", line 825, in read_utf
    result = self.data[offset:offset + len].decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

RFC 6763

I've started to write service from scratch based on most recent version of the RFC 6763.
You could follow the work here: https://github.com/GreatFruitOmsk/mdns/tree/new_service

The main goal is to pre-validate and provide as much feedback as possible to the developer to simplify writing a robust code. The idea is also to provide a sufficient documentation so developer could understand most of the RFC from the code.

@svinota Please tell me what you think about this.

How to advertise a service?

It appears that mdns is a bit inaccurate in documentation. In example:

class ServiceInfo(object):
    """Service information"""

    def __init__(self, type, name, address=None, port=None, weight=0,
            priority=0, properties=None, server=None, records=None,
            ttl=_DNS_TTL, signer=None):
        """Create a service description.

        domain: fully qualified service type name
        name: fully qualified service name
        address: IP address as unsigned short, network byte order
        port: port that the service runs on
        weight: weight of the service
        priority: priority of the service
        properties: dictionary of properties (or a string holding the bytes
            for the text field)
        server: fully qualified name for service host (defaults to name)"""
  • There is no domain anymore. It was replaced by type. As far as I understand possible values are defined in RFC 2782.
  • It appears that name MUST end with type.
  • address description appears to be inaccurate: it's obviously not unsigned short. As far as I understood from the code, it should be inet_aton (inet_pton?) representation.
  • port should be "unsigned short, network byte order"
    Other properties are not clear to me either (some reference to the docs would be helpful)

But how one supposed to advertise a service? I'm trying:

z = Zeroconf()
ServiceInfo('_tcp.', 'blablabla._tcp.', address=socket.inet_aton('192.168.1.10'), port=socket.htons(25000))
z.register_service(i)

But I don't see service in the Bonjour Browser app.
Could you be so kind and point me where I'm wrong?

Registering a service in a thread

When I try to register a service in a thread, I get this :

Exception in thread Thread-7:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 921, in _bootstrap_inner
    self.run()
  File "/home/nemo/dev/HeySms/heysms/lib/friend.py", line 103, in run
    info = ServiceInfo(d, n, inet_aton('192.168.2.38'), 12345, properties=txt)
  File "./embedded_libs/mdns/zeroconf.py", line 1362, in __init__
    self.set_properties(self.properties)
  File "./embedded_libs/mdns/zeroconf.py", line 1388, in set_properties
    self.sync_properties()
  File "./embedded_libs/mdns/zeroconf.py", line 1382, in sync_properties
    self.text = dict_to_text(self.properties)
  File "./embedded_libs/mdns/zeroconf.py", line 231, in dict_to_text
    list.append('='.join((key, suffix)))
TypeError: sequence item 1: expected str instance, bytes found

You can see the code here : https://github.com/titilambert/HeySms/blob/master/heysms/lib/friend.py

Python 3 support

Hello !
I'm trying to run mdns on python3 (3.4)
I get this error:

Traceback (most recent call last):
  File "/home/nemo/dev/HeySms/snipets/bad/mdns/zeroconf.py", line 1131, in run
    self.readers[socket].handle_read()
  File "/home/nemo/dev/HeySms/snipets/bad/mdns/zeroconf.py", line 1178, in handle_read
    msg = DNSIncoming(data)
  File "/home/nemo/dev/HeySms/snipets/bad/mdns/zeroconf.py", line 684, in __init__
    self.read_others()
  File "/home/nemo/dev/HeySms/snipets/bad/mdns/zeroconf.py", line 754, in read_others
    domain = self.read_name()
  File "/home/nemo/dev/HeySms/snipets/bad/mdns/zeroconf.py", line 829, in read_name
    len = ord(self.data[off])
TypeError: ord() expected string of length 1, but int found

How to browse services ?

Hello !
I'm trying to use your beautiful lib !
I succeed to register my service using issue #3 .
Now I'm trying to use the Service Browser.
Could you give me an example of it ?
After I finish my tests, I could submit a pull request with some basic examples if you want.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.