def encode_dns(name): out = [] for part in name.split('.'): if len(part) == 0: continue out.append(ToASCII(part)) return '.'.join(out)
def createRR(name): out = [] for part in name.split('.'): if len(part) == 0: continue out.append(chr(len(part))) out.append(ToASCII(part)) out.append('\0') return ''.join(out)
def encode_cname(self, name): return '.'.join(ToASCII(p) for p in name.split('.') if p)
def enc(part): a = ToASCII(part) return chr(len(a)), a
def encode(self, name): """ convert the string to ascii copied from https://gist.github.com/gdamjan/3168336 """ return '.'.join(ToASCII(p) for p in name.split('.') if p)