| 280 | # Finished |
| 281 | class TXT(DNSResponse): |
| 282 | def __init__(self, query, txt_record): |
| 283 | super(TXT, self).__init__(query) |
| 284 | self.type = b"\x00\x10" |
| 285 | self.data = txt_record.encode() |
| 286 | self.length = chr(len(txt_record) + 1).encode() |
| 287 | # Must be two bytes. This is the better, more python-3 way to calculate length. Swap to this later. |
| 288 | if len(self.length) < 2: |
| 289 | self.length = b"\x00" + self.length |
| 290 | # Then, we have to add the TXT record length field! We utilize the |
| 291 | # length field for this since it is already in the right spot |
| 292 | self.length += chr(len(txt_record)).encode() |
| 293 | |
| 294 | |
| 295 | class MX(DNSResponse): |