How to use the zeroconf.DNSText function in zeroconf

To help you get started, we’ve selected a few zeroconf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wmcbrine / tivoremote / zeroconf.py View on Github external
self.servicetypes[info.type]=1
        now = currentTimeMillis()
        nextTime = now
        i = 0
        while i < 3:
            if now < nextTime:
                self.wait(nextTime - now)
                now = currentTimeMillis()
                continue
            out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
            out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR, 
                _CLASS_IN, ttl, info.name), 0)
            out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV, 
                _CLASS_IN, ttl, info.priority, info.weight, info.port, 
                info.server), 0)
            out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN, 
                ttl, info.text), 0)
            if info.address:
                out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A, 
                    _CLASS_IN, ttl, info.address), 0)
            self.send(out)
            i += 1
            nextTime += _REGISTER_TIME
github wmcbrine / hmeforpython / zeroconf.py View on Github external
pass
        now = currentTimeMillis()
        nextTime = now
        i = 0
        while i < 3:
            if now < nextTime:
                self.wait(nextTime - now)
                now = currentTimeMillis()
                continue
            out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
            out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR,
                _CLASS_IN, 0, info.name), 0)
            out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV,
                _CLASS_IN, 0, info.priority, info.weight, info.port,
                info.name), 0)
            out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN,
                0, info.text), 0)
            if info.address:
                out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A,
                    _CLASS_IN, 0, info.address), 0)
            self.send(out)
            i += 1
            nextTime += _UNREGISTER_TIME
github wmcbrine / tivoremote / zeroconf.py View on Github external
now = currentTimeMillis()
            nextTime = now
            i = 0
            while i < 3:
                if now < nextTime:
                    self.wait(nextTime - now)
                    now = currentTimeMillis()
                    continue
                out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
                for info in self.services.values():
                    out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR, 
                        _CLASS_IN, 0, info.name), 0)
                    out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV, 
                        _CLASS_IN, 0, info.priority, info.weight, 
                        info.port, info.server), 0)
                    out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, 
                        _CLASS_IN, 0, info.text), 0)
                    if info.address:
                        out.addAnswerAtTime(DNSAddress(info.server, 
                            _TYPE_A, _CLASS_IN, 0, info.address), 0)
                self.send(out)
                i += 1
                nextTime += _UNREGISTER_TIME
github wmcbrine / tivoremote / zeroconf.py View on Github external
pass
        now = currentTimeMillis()
        nextTime = now
        i = 0
        while i < 3:
            if now < nextTime:
                self.wait(nextTime - now)
                now = currentTimeMillis()
                continue
            out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
            out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR, 
                _CLASS_IN, 0, info.name), 0)
            out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV, 
                _CLASS_IN, 0, info.priority, info.weight, info.port, 
                info.name), 0)
            out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN, 
                0, info.text), 0)
            if info.address:
                out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A, 
                    _CLASS_IN, 0, info.address), 0)
            self.send(out)
            i += 1
            nextTime += _UNREGISTER_TIME
github wmcbrine / hmeforpython / zeroconf.py View on Github external
self.servicetypes[info.type] = 1
        now = currentTimeMillis()
        nextTime = now
        i = 0
        while i < 3:
            if now < nextTime:
                self.wait(nextTime - now)
                now = currentTimeMillis()
                continue
            out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
            out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR,
                _CLASS_IN, ttl, info.name), 0)
            out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV,
                _CLASS_IN, ttl, info.priority, info.weight, info.port,
                info.server), 0)
            out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN,
                ttl, info.text), 0)
            if info.address:
                out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A,
                    _CLASS_IN, ttl, info.address), 0)
            self.send(out)
            i += 1
            nextTime += _REGISTER_TIME
github wmcbrine / tivoremote / zeroconf.py View on Github external
def readOthers(self):
        """Reads the answers, authorities and additionals section of the 
        packet"""
        n = self.numAnswers + self.numAuthorities + self.numAdditionals
        for i in xrange(n):
            domain = self.readName()
            type, clazz, ttl, length = self.unpack('!HHiH')

            rec = None
            if type == _TYPE_A:
                rec = DNSAddress(domain, type, clazz, ttl, self.readString(4))
            elif type == _TYPE_CNAME or type == _TYPE_PTR:
                rec = DNSPointer(domain, type, clazz, ttl, self.readName())
            elif type == _TYPE_TXT:
                rec = DNSText(domain, type, clazz, ttl, self.readString(length))
            elif type == _TYPE_SRV:
                rec = DNSService(domain, type, clazz, ttl,
                    self.readUnsignedShort(), self.readUnsignedShort(),
                    self.readUnsignedShort(), self.readName())
            elif type == _TYPE_HINFO:
                rec = DNSHinfo(domain, type, clazz, ttl,
                    self.readCharacterString(), self.readCharacterString())
            elif type == _TYPE_AAAA:
                rec = DNSAddress(domain, type, clazz, ttl, self.readString(16))
            else:
                # Try to ignore types we don't know about
                # Skip the payload for the resource record so the next
                # records can be parsed correctly
                self.offset += length

            if rec is not None:
github wmcbrine / tivoremote / zeroconf.py View on Github external
def __eq__(self, other):
        """Tests equality on text"""
        return isinstance(other, DNSText) and self.text == other.text
github wmcbrine / hmeforpython / zeroconf.py View on Github external
def readOthers(self):
        """Reads the answers, authorities and additionals section of the
        packet"""
        n = self.numAnswers + self.numAuthorities + self.numAdditionals
        for i in xrange(n):
            domain = self.readName()
            type, clazz, ttl, length = self.unpack('!HHiH')

            rec = None
            if type == _TYPE_A:
                rec = DNSAddress(domain, type, clazz, ttl, self.readString(4))
            elif type == _TYPE_CNAME or type == _TYPE_PTR:
                rec = DNSPointer(domain, type, clazz, ttl, self.readName())
            elif type == _TYPE_TXT:
                rec = DNSText(domain, type, clazz, ttl, self.readString(length))
            elif type == _TYPE_SRV:
                rec = DNSService(domain, type, clazz, ttl,
                    self.readUnsignedShort(), self.readUnsignedShort(),
                    self.readUnsignedShort(), self.readName())
            elif type == _TYPE_HINFO:
                rec = DNSHinfo(domain, type, clazz, ttl,
                    self.readCharacterString(), self.readCharacterString())
            elif type == _TYPE_AAAA:
                rec = DNSAddress(domain, type, clazz, ttl, self.readString(16))
            else:
                # Try to ignore types we don't know about
                # Skip the payload for the resource record so the next
                # records can be parsed correctly
                self.offset += length

            if rec is not None: