amazon-route-53-dns-zone-file
Version:
Makes DNS Zone File easy. Parses and validates BIND zone files and can be extended for custom features. Functionality is modular. Features are made open for extension and closed for runtime mutation. Written in TypeScript.
511 lines (437 loc) • 11.8 kB
text/typescript
/**
* === general ===
*/
export const optionalTTLAndClass = `
$ORIGIN igloo.com.
$TTL 4242
igloo.com. 42s SOA ns.igloo.com. username.igloo.com. 1 2 3 4 5
neither A 1.2.3.4
ttl 42s A 1.2.3.4
class IN A 1.2.3.4
ttl.class 42s IN A 1.2.3.4
class.ttl IN 42s A 1.2.3.4
`;
export const comments1 = `
$ORIGIN igloo.com.
;comments should be ignored
;every comment, even ascii ©¿
eh 42s A 2.3.4.5
;comment
www 42s IN A 1.2.3.4
`;
export const nameNotTooLong = `
$ORIGIN igloo.com.
1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.1234567890.igloo.com. 60 IN A 1.2.3.4
`;
export const utfCharacters = `
$ORIGIN igloo.com.
©.igloo.com. 42s IN A 1.2.3.4
¿.igloo.com. 42s IN A 1.2.3.4
`;
export const escapeInTXT = `
$ORIGIN igloo.com.
www 42s IN TXT "\\101\\"
`;
export const escapeInCNAMEValue = `
$ORIGIN igloo.com.
www 42s IN CNAME \\008\\99.igloo.com.
`;
export const defaultOrigin = `
$ORIGIN igloo.com.
@ 42s IN A 1.2.3.4
www 42s IN A 1.2.3.4
`;
export const specialTTL = `
$ORIGIN igloo.com.
$TTL 42s
eh A 2.3.4.5
`;
export const backwardsTTL = `
$ORIGIN igloo.com.
42s eh IN A 2.3.4.5
`;
export const ttlWithNameSimilarToTTL = `
$ORIGIN igloo.com.
100.canada. 42s IN A 2.3.4.5
`;
/**
* === ptr ===
*/
export const ptrExampleOneEntryTopLevelTTL = `
$ORIGIN 11.igloo.com.
$TTL 42s
99 PTR HOST1.igloo.com.
`;
export const ptrExampleInlineTTL = `
$ORIGIN 0.168.192.igloo.com.
1 42s PTR HOST1.igloo.com.
2 42s PTR HOST2.igloo.com.
`;
export const ptrExampleTopLevelTTL = `
$ORIGIN 0.168.192.igloo.com.
$TTL 42s
1 PTR HOST1.igloo.com.
2 PTR HOST2.igloo.com.
`;
export const ptrExampleNestedTopLevelTTL = `
$ORIGIN 30.168.192.igloo.com
$TTL 42s
3 PTR HOST3.igloo.com.
4 PTR HOST4.igloo.com.
PTR HOST5.igloo.com.
IN PTR HOST6.igloo.com.
`;
export const ptrExampleDecimals = `
$ORIGIN 168.192.igloo.com
$TTL 42s
10.3 PTR HOST3.igloo.com.
10.4 PTR HOST4.igloo.com.
`;
export const ptrMultipleOrigins = `
$TTL 40s
$ORIGIN 30.168.192.igloo.com
3 41s PTR HOST3.igloo.com.
4 42s PTR HOST4.igloo.com.
43s PTR HOST5.igloo.com.
44s IN PTR HOST6.igloo.com.
$ORIGIN 168.192.igloo.com
10.3 45s PTR HOST3.igloo.com.
10.4 46s PTR HOST4.igloo.com.
`;
export const ptrMultipleOriginsAndMultipleTTL = `
$ORIGIN 30.168.192.igloo.com
$TTL 42s
3 PTR HOST3.igloo.com.
4 PTR HOST4.igloo.com.
PTR HOST5.igloo.com.
IN PTR HOST6.igloo.com.
$ORIGIN 168.192.igloo.com
$TTL 60s
10.3 PTR HOST3.igloo.com.
10.4 PTR HOST4.igloo.com.
`;
/**
* === a-aaaa ===
* @note without $origin, it uses `0:0:0:0:0:0:0:1`
*/
export const aaaaWithNameAndTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
example AAAA ::1
`;
export const aaaaWithAtNameAndInlineTTL = `
$ORIGIN igloo.com.
@ 42s AAAA ::1
`;
export const aWithNameAndTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
example A 127.0.0.1
`;
export const aWithAtNameAndInlineTTL = `
$ORIGIN igloo.com.
@ 42s A 127.0.0.1
`;
/**
* === txt ===
*/
export const txtExampleTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
treefrog.igloo.com. IN TXT "v=spf1 a mx a:mail.treefrog.ca a:webmail.treefrog.ca ip4:76.75.250.33 ?all"
treemonkey.igloo.com. IN TXT "v=DKIM1\; k=rsa\; p=MIGf..."
treemonkey1.igloo.com. IN TXT "v=DKIM1\; k=rsa\; p=MIGf..."
`;
export const parensInTXT = `
$ORIGIN igloo.com.
eh 42s IN TXT "Some text (Moose)"
TXT "spaced ( spaces1 spaces2 )"
`;
export const txtExampleInlineTTL = `
$ORIGIN igloo.com.
treefrog.igloo.com. 42s IN TXT "v=spf1 a mx a:mail.treefrog.ca a:webmail.treefrog.ca ip4:76.75.250.33 ?all"
treemonkey.igloo.com. 42s IN TXT "v=DKIM1\; k=rsa\; p=MIGf..."
treemonkey1.igloo.com. 42s IN TXT "v=DKIM1\; k=rsa\; p=MIGf..."
`;
export const txtExampleNested = `
$ORIGIN igloo.com.
$TTL 42s
treefrog.igloo.com. TXT "eh=true"
TXT "moose=DKIM1\; beaver=canada\;"
`;
/**
* === spf ===
*/
export const spfExampleOneEntryInlineTTL = `
$ORIGIN igloo.com.
test 42s IN SPF "v=spf1" "mx:gcloud-node.com." "-all"
`;
export const spfExampleNestedTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
test IN SPF "v=spf1" "mx:gcloud-node.com." "-all"
test1 SPF "v=spf2" "mx:gcloud-node.com." "-all"
IN SPF "v=spf3" "mx:gcloud-node.com." "-all "
SPF "v=spf4" "mx:gcloud-node.com." "-all"
`;
export const spfExampleNestedInlineTTL = `
$ORIGIN igloo.com.
test 42s IN SPF "v=spf1" "mx:gcloud-node.com." "-all"
test1 42s SPF "v=spf2" "mx:gcloud-node.com." "-all"
IN SPF "v=spf3" "mx:gcloud-node.com." "-all "
SPF "v=spf4" "mx:gcloud-node.com." "-all"
`;
export const spfExampleAtNameInlineTTL = `
$ORIGIN igloo.com.
@ 42s IN TXT "v=spf1 a mx ~all"
`;
export const spfMaxValues = `
eh 42s SPF v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.123 a -all
`;
export const spfMinValues = `
eh 42s SPF v=spf1 ip:4:192.168.0.1/16-all
`;
export const spfExampleOfOneParam = `
eh 42s SPF "v=spf1 ip:4:192.168.0.1/16"
`;
/**
* === caa ===
*/
export const caaExampleIssueAndIoDefAndTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
@ CAA 0 issue "ca.igloo.com"
@ CAA 0 iodef "mailto:security@igloo.com"
@ CAA 0 iodef "http://iodef.igloo.com/"
`;
export const caaExampleIssueAndIoDefAndTopLevelTTLNoQuotes = `
$ORIGIN igloo.com.
$TTL 42s
@ CAA 0 issue ca.igloo.com
@ CAA 0 iodef mailto:security.com
@ CAA 0 iodef http://iodef.igloo.com/
`;
/**
* `0 iodef "mailto:security@igloo.com"`
*/
export const caaExampleJustIoDef = `
igloo.com 42s CAA 0 iodef "mailto:security@igloo.com"
`;
export const caaExampleInlineTTL = `
@ 42s CAA 0 issue "ca.igloo.com"
@ 42s CAA 0 iodef "mailto:security@igloo.com"
`;
export const caaExampleJustIssue = `
$ORIGIN igloo.com.
@ 42s CAA 0 issue "ca.igloo.com"
`;
// not valid...
// export const caaExampleJustIssueNoNameInlineTTL = `
// $ORIGIN igloo.com.
// 42s CAA 0 issue "ca.igloo.com"
// `;
export const caaExampleJustIssueNoNameTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
CAA 0 issue "ca.igloo.com"
`;
export const caaExampleJustIssueWithInNoNameTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
IN CAA 0 issue "ca.igloo.com"
`;
/**
* === naptr ===
*/
export const naptrExampleTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
IN NAPTR 100 10 "U" "E2U+sip" "!^.*$!sip:customer-service@example.com!" .
IN NAPTR 102 10 "U" "E2U+email" "!^.*$!mailto:information@example.com!" .
`;
/**
* 100 10 "u" "sip+E2U" "!^.*$!sip:information@foo.se!i" .
* 100 50 "a" "z3950+N2L+N2C" "" cidserver.igloo.com.
*
* @example
* 10 10 "S" "SIP+D2U" "" igloo.com
* 100 50 "a" "z3950+N2L+N2C" "" cidserver.igloo.com.
* @format `[order][preference][flags][services][regexp][replacement]`
*/
export const naptrExample1 = `
$ORIGIN igloo.com.
rfc3403-1 42s IN NAPTR 100 10 "u" "sip+E2U" "!^.*$!sip:information@foo.se!i" .
rfc3403-2 42s IN NAPTR 100 50 "a" "z3950+N2L+N2C" "" cidserver.igloo.com.
`;
export const naptrExampleInlineTTLAndNested = `
$ORIGIN igloo.com.
rfc3403-1 42s IN NAPTR 100 10 "u" "sip+E2U" "!^.*$!sip:information@foo.se!i" .
rfc3403-2 42s IN NAPTR 100 50 "a" "z3950+N2L+N2C" "" cidserver.igloo.com.
@ 42s IN NAPTR 99 98 "B" "E2U+siz" "" .
IN NAPTR 100 10 "U" "E2U+sip" "!^.*$!sip:customer-service@example.com!" .
IN NAPTR 102 10 "U" "E2U+email" "!^.*$!mailto:information@example.com!" .
`;
/**
* === svr ===
*/
export const srvExampleWithNameAndTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
; foobar - use old-slow-box or new-fast-box if either is
; available, make three quarters of the logins go to
; new-fast-box.
_foobar._tcp SRV 0 1 9 old-slow-box.igloo.com.
SRV 0 3 9 new-fast-box.igloo.com.
; if neither old-slow-box or new-fast-box is up, switch to
; using the sysdmin's box and the server
SRV 1 0 9 sysadmins-box.igloo.com.
SRV 1 0 9 server.igloo.com.
server A 172.30.79.10
old-slow-box A 172.30.79.11
sysadmins-box A 172.30.79.12
new-fast-box A 172.30.79.13
; NO other services are supported
*._tcp SRV 0 0 0 .
*._udp SRV 0 0 0 .
`;
/**
* @note this is not really valid, but we are handling it
*/
export const srvExampleWithNameAndInlineTTL = `
$ORIGIN igloo.com.
_foobar._tcp 42s SRV 0 1 9 old-slow-box.igloo.com.
42s SRV 0 3 9 new-fast-box.igloo.com.
42s SRV 1 0 9 sysadmins-box.igloo.com.
42s SRV 1 0 9 server.igloo.com.
*._tcp 42s SRV 0 0 0 .
*._udp 42s SRV 0 0 0 .
`;
export const srvExampleWithNameAndInlineTTLMoreValid = `
$ORIGIN igloo.com.
_foobar._tcp 42s SRV 0 1 9 old-slow-box.igloo.com.
IN SRV 0 3 9 new-fast-box.igloo.com.
SRV 1 0 9 sysadmins-box.igloo.com.
SRV 1 0 9 server.igloo.com.
*._tcp 42s SRV 0 0 0 .
*._udp 42s SRV 0 0 0 .
`;
/**
* === ns ===
*/
export const nsExampleWithAtAndTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
@ NS NS1.NAMESERVER.NET.
@ NS NS2.NAMESERVER.NET.
`;
export const nsExampleWithNoNameAndTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
NS NS1.NAMESERVER.NET.
NS NS2.NAMESERVER.NET.
`;
export const nsExampleWithNamesAndTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
syrup NS NS1.NAMESERVER.NET.
beaver NS NS2.NAMESERVER.NET.
`;
export const nsExampleInlineTTL = `
$ORIGIN igloo.com.
eh 42s NS NS1.NAMESERVER.NET.
canada 42s NS NS2.NAMESERVER.NET.
`;
export const nsExampleNestedWithTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
moose NS NS1.NAMESERVER.NET.
NS NS2.NAMESERVER.NET.
`;
/**
* === general ===
*/
/**
* if missing in ui, it uses hz.name
*/
export const nameMissing = `
$ORIGIN igloo.com.
$TTL 100
100 NS ns.igloo.com.
`;
/**
* === mx ===
*/
export const mxExampleAt = `
$ORIGIN igloo.com.
$TTL 42s
@ MX 0 mail1
@ MX 10 mail2
`;
/**
* === cname ===
*/
export const cnameWithTopLevelTTL = `
$ORIGIN igloo.com.
$TTL 42s
mail1 CNAME mail
mail2 CNAME mail
`;
export const cnameWithInlineAndSpacesTTL = `
$ORIGIN igloo.com.
mail1 42s CNAME mail
mail2 60s CNAME mail
`;
/**
* === soa ===
*/
export const soaIsIgnored1 = `
$ORIGIN igloo.com.
@ SOA server.igloo.com. hostprimary.igloo.com. (
1995032001 3600 3600 604800 42s )
NS server.igloo.com.
`;
export const soaIsIgnored2 = `
$ORIGIN igloo.com.
@ IN SOA NS1.NAMESERVER.NET. HOSTPRIMARY.igloo.com. (
1406291485 ;serial
3600 ;refresh
600 ;retry
604800 ;expire
42s ;minimum ttl
)
example A 127.0.0.1
`;
export const soaIsIgnored3 = `
@ IN SOA NS1.NAMESERVER.NET. HOSTPRIMARY.igloo.com. (
1406291485 ;serial
3600 ;refresh
600 ;retry
604800 ;expire
42s ;minimum ttl
)
@ IN SOA server.igloo.com igloo.com (
1406291485 ;serial
3600 ;refresh
600 ;retry
604800 ;expire
42s ;minimum ttl
)
@ IN SOA ns.igloo.com. username.igloo.com. (
2007120710 ; serial number of this zone file
1d ; secondary refresh (1 day)
2h ; secondary retry time in case of a problem (2 hours)
4w ; secondary expiration time (4 weeks)
1h ; maximum caching time in case of failed lookups (1 hour)
)
igloo.com. 100 SOA ns.igloo.com. username.igloo.com. 1 2 3 4 5
mail1 CNAME mail
`;
export const simpleSoa = `
@ IN SOA eh(
11
2
33
4
55
)
`;