(self,name)
Encode label and store at end of buffer (compressing
            cached elements where needed) and store elements
            in 'names' dict
Encode label and store at end of buffer (compressing
            cached elements where needed) and store elements
            in 'names' dict
Encode label and store at end of buffer ( compressing cached elements where needed ) and store elements in names dict
def encode_name(self,name):
        """
            Encode label and store at end of buffer (compressing
            cached elements where needed) and store elements
            in 'names' dict
        """
        if not isinstance(name,DNSLabel):
            name = DNSLabel(name)
        if len(name) > 253:
            raise DNSLabelError("Domain label too long: %r" % name)
        name = list(name.label)
        while name:
            if tuple(name) in self.names:
                # Cached - set pointer
                pointer = self.names[tuple(name)]
                pointer = set_bits(pointer,3,14,2)
                self.pack("!H",pointer)
                return
            else:
                self.names[tuple(name)] = self.offset
                element = name.pop(0)
                if len(element) > 63:
                    raise DNSLabelError("Label component too long: %r" % element)
                self.pack("!B",len(element))
                self.append(element)
        self.append(b'\x00')
def encode_name ( self , name ) : if not isinstance ( name , DNSLabel ) : name = DNSLabel ( name ) if len ( name ) > 253 : raise DNSLabelError ( "Domain label too long: %r" % name ) name = list ( name . label ) while name : if tuple ( name ) in self . names : # Cached - set pointer pointer = self . names [ tuple ( name ) ] pointer = set_bits ( pointer , 3 , 14 , 2 ) self . pack ( "!H" , pointer ) return else : self . names [ tuple ( name ) ] = self . offset element = name . pop ( 0 ) if len ( element ) > 63 : raise DNSLabelError ( "Label component too long: %r" % element ) self . pack ( "!B" , len ( element ) ) self . append ( element ) self . append ( b'\x00' )