dns.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. Language: DNS Zone
  3. Author: Tim Schumacher <tim@datenknoten.me>
  4. Category: config
  5. Website: https://en.wikipedia.org/wiki/Zone_file
  6. */
  7. /** @type LanguageFn */
  8. function dns(hljs) {
  9. const KEYWORDS = [
  10. "IN",
  11. "A",
  12. "AAAA",
  13. "AFSDB",
  14. "APL",
  15. "CAA",
  16. "CDNSKEY",
  17. "CDS",
  18. "CERT",
  19. "CNAME",
  20. "DHCID",
  21. "DLV",
  22. "DNAME",
  23. "DNSKEY",
  24. "DS",
  25. "HIP",
  26. "IPSECKEY",
  27. "KEY",
  28. "KX",
  29. "LOC",
  30. "MX",
  31. "NAPTR",
  32. "NS",
  33. "NSEC",
  34. "NSEC3",
  35. "NSEC3PARAM",
  36. "PTR",
  37. "RRSIG",
  38. "RP",
  39. "SIG",
  40. "SOA",
  41. "SRV",
  42. "SSHFP",
  43. "TA",
  44. "TKEY",
  45. "TLSA",
  46. "TSIG",
  47. "TXT"
  48. ];
  49. return {
  50. name: 'DNS Zone',
  51. aliases: [
  52. 'bind',
  53. 'zone'
  54. ],
  55. keywords: KEYWORDS,
  56. contains: [
  57. hljs.COMMENT(';', '$', { relevance: 0 }),
  58. {
  59. className: 'meta',
  60. begin: /^\$(TTL|GENERATE|INCLUDE|ORIGIN)\b/
  61. },
  62. // IPv6
  63. {
  64. className: 'number',
  65. begin: '((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))\\b'
  66. },
  67. // IPv4
  68. {
  69. className: 'number',
  70. begin: '((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\b'
  71. },
  72. hljs.inherit(hljs.NUMBER_MODE, { begin: /\b\d+[dhwm]?/ })
  73. ]
  74. };
  75. }
  76. export { dns as default };