Skip to content

Workaround for IDNs in answer (and a typo fix)

John Shaft requested to merge Shaft/mastodon-chinese-DNS-bot:original into master
  1. Added a function to decode IDNs in answers. It is used for all records type but TXT so it should close #29.

A few remarks:

  • No IDNs decoding in TXT records. If there is a punycode-encoded name in a TXT, it is here on purpose
  • I chose a solution where answer is first encoded in a utf-8 string and then parsed for 'xn--' substrings. Those substrings are then converted to dns.name.Name and re-encoded in nice looking utf-8. I could I have used Python's punycode codec to decode but it requires to remove trailing dot from substrings, convert them to bytes object, decode and putting back the dot. Tedious
  • Another solution was to parse the dns.rrset objet returned by the resolver function but it actually failed because of the diversity of things in RRs (like hex, base64, base32... encoded stuff - eg. https://piaille.fr/@shaft/111857616702466579)
  1. Fixed a typo in log creation (close #26)
Edited by John Shaft

Merge request reports