@dzfu/parser
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

@dzfu/parser

dns zonefile parser

Build Status License: MIT

Install

yarn add @dzfu/parser

Usage

import { RR } from "@dzfu/core";
import { parseZone } from "@dzfu/parser";

const text = `
$TTL  3600
@ IN  SOA ns.example1.com. root.example1.com. (
  20190101  ; serial
  3600 ; refresh
  3600 ; retry
  1209600 ; expire
  3600 ; negative cache ttl
)

; NS records

@  IN  NS  ns.example1.com.
@  IN  NS  ns2.example1.com. 

; A records

localhost.example1.com. IN  A 127.0.0.1
ns.example1.com.  IN  A 192.1.2.2
ns2.example1.com. IN  A 192.1.2.3
bug.example1.com. IN  A 192.249.249.1
dog IN  A 192.249.249.2
cat IN  A 192.249.249.3
shark IN  A 192.249.249.4

; CNAME records

foo.example1.com.  IN  CNAME example2.com.
bar.example1.com.  IN  CNAME foo.example2.com.
`;

const rrs: RR[] = parseZone(text, "example1.com.");
console.log(rrs);
/**
Array [
  Object {
    "class": 0,
    "expire": 1209600,
    "mbox": "root.example1.com.",
    "minttl": 3600,
    "name": "example1.com.",
    "ns": "ns.example1.com.",
    "refresh": 3600,
    "retry": 3600,
    "rrtype": 5,
    "serial": 20190101,
    "ttl": 3600,
  },
  Object {
    "class": 0,
    "name": "example1.com.",
    "ns": "ns.example1.com.",
    "rrtype": 3,
    "ttl": 3600,
  },

  ...,

  Object {
    "class": 0,
    "name": "bar.example1.com.",
    "rrtype": 0,
    "target": "foo.example2.com.",
    "ttl": 3600,
  },
]
*/

Readme

Keywords

Package Sidebar

Install

npm i @dzfu/parser

Weekly Downloads

2

Version

0.1.3

License

MIT

Unpacked Size

3.99 kB

Total Files

3

Last publish

Collaborators

  • koyamaso