zonefile-parser
Version:
zonefile DNS configuration parser
1,497 lines (1,413 loc) • 164 kB
JavaScript
module.exports = (function() {
"use strict";
/*
* Generated by PEG.js 0.9.0.
*
* http://pegjs.org/
*/
function peg$subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function peg$SyntaxError(message, expected, found, location) {
this.message = message;
this.expected = expected;
this.found = found;
this.location = location;
this.name = "SyntaxError";
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, peg$SyntaxError);
}
}
peg$subclass(peg$SyntaxError, Error);
function peg$parse(input) {
var options = arguments.length > 1 ? arguments[1] : {},
parser = this,
peg$FAILED = {},
peg$startRuleFunctions = { Zonefile: peg$parseZonefile },
peg$startRuleFunction = peg$parseZonefile,
peg$c0 = function(directives, records) {
return {
origin: findNoneOneOrError(directives, 'origin'),
ttl: findNoneOneOrError(directives, 'ttl'),
records: records.filter(r => !Array.isArray(r)) // Remove blank lines / comments
}
function findNoneOneOrError (arr, prop) {
var results = arr.filter(item => !!item[prop])
if (results.length === 0) return null
if (results.length === 1) return results[0][prop]
return error('Zonefile has ' + results.length + ' $' + prop.toUpperCase() + ' directives. A valid zonefile has 1 or none.')
}
},
peg$c1 = "$ORIGIN",
peg$c2 = { type: "literal", value: "$ORIGIN", description: "\"$ORIGIN\"" },
peg$c3 = function(origin) { return { origin: origin } },
peg$c4 = "$TTL",
peg$c5 = { type: "literal", value: "$TTL", description: "\"$TTL\"" },
peg$c6 = function(ttl) { return { ttl: ttl } },
peg$c7 = "A",
peg$c8 = { type: "literal", value: "A", description: "\"A\"" },
peg$c9 = function(intro, type, address) {
return {
name: intro.name,
ttl: intro.ttl,
type: type,
data: address
}
},
peg$c10 = "AAAA",
peg$c11 = { type: "literal", value: "AAAA", description: "\"AAAA\"" },
peg$c12 = "CNAME",
peg$c13 = { type: "literal", value: "CNAME", description: "\"CNAME\"" },
peg$c14 = function(intro, type, domain) {
return {
name: intro.name,
ttl: intro.ttl,
type: type,
data: domain
}
},
peg$c15 = "MX",
peg$c16 = { type: "literal", value: "MX", description: "\"MX\"" },
peg$c17 = function(intro, type, preference, domain) {
return {
name: intro.name,
ttl: intro.ttl,
type: type,
data: { preference: preference, domain: domain }
}
},
peg$c18 = "NS",
peg$c19 = { type: "literal", value: "NS", description: "\"NS\"" },
peg$c20 = function(intro, type, nameServer) {
return {
name: intro.name,
ttl: intro.ttl,
type: type,
data: nameServer
}
},
peg$c21 = "SOA",
peg$c22 = { type: "literal", value: "SOA", description: "\"SOA\"" },
peg$c23 = "(",
peg$c24 = { type: "literal", value: "(", description: "\"(\"" },
peg$c25 = ")",
peg$c26 = { type: "literal", value: ")", description: "\")\"" },
peg$c27 = function(intro, type, nameServer, email, serial, refresh, retry, expiry, minimum) {
return {
name: intro.name,
ttl: intro.ttl,
type: type,
data: { nameServer: nameServer, email:email, serial:serial, refresh:refresh, retry:retry, expiry:expiry, minimum:minimum }
}
},
peg$c28 = "SRV",
peg$c29 = { type: "literal", value: "SRV", description: "\"SRV\"" },
peg$c30 = function(intro, type, priority, weight, port, target) {
return {
name: intro.name,
ttl: intro.ttl,
type: type,
data: { priority: priority, weight: weight, port: port, target: target }
}
},
peg$c31 = "TXT",
peg$c32 = { type: "literal", value: "TXT", description: "\"TXT\"" },
peg$c33 = function(intro, type, strings) {
return {
name: intro.name,
ttl: intro.ttl,
type: type,
data: strings.join('')
}
},
peg$c34 = function(intro, type, data) {
return {
name: intro.name,
ttl: intro.ttl,
type: type,
data: data
}
},
peg$c35 = function(name, ttl) {
return {
name:name,
ttl: ttl
}
},
peg$c36 = "@",
peg$c37 = { type: "literal", value: "@", description: "\"@\"" },
peg$c38 = function(name) { return name },
peg$c39 = "IN",
peg$c40 = { type: "literal", value: "IN", description: "\"IN\"" },
peg$c41 = "X25",
peg$c42 = { type: "literal", value: "X25", description: "\"X25\"" },
peg$c43 = "WKS",
peg$c44 = { type: "literal", value: "WKS", description: "\"WKS\"" },
peg$c45 = "URI",
peg$c46 = { type: "literal", value: "URI", description: "\"URI\"" },
peg$c47 = "UNSPEC",
peg$c48 = { type: "literal", value: "UNSPEC", description: "\"UNSPEC\"" },
peg$c49 = "UINFO",
peg$c50 = { type: "literal", value: "UINFO", description: "\"UINFO\"" },
peg$c51 = "UID",
peg$c52 = { type: "literal", value: "UID", description: "\"UID\"" },
peg$c53 = "TSIG",
peg$c54 = { type: "literal", value: "TSIG", description: "\"TSIG\"" },
peg$c55 = "TLSA",
peg$c56 = { type: "literal", value: "TLSA", description: "\"TLSA\"" },
peg$c57 = "TKEY",
peg$c58 = { type: "literal", value: "TKEY", description: "\"TKEY\"" },
peg$c59 = "TALINK",
peg$c60 = { type: "literal", value: "TALINK", description: "\"TALINK\"" },
peg$c61 = "TA",
peg$c62 = { type: "literal", value: "TA", description: "\"TA\"" },
peg$c63 = "SSHFP",
peg$c64 = { type: "literal", value: "SSHFP", description: "\"SSHFP\"" },
peg$c65 = "SPF",
peg$c66 = { type: "literal", value: "SPF", description: "\"SPF\"" },
peg$c67 = "SMIMEA",
peg$c68 = { type: "literal", value: "SMIMEA", description: "\"SMIMEA\"" },
peg$c69 = "SINK",
peg$c70 = { type: "literal", value: "SINK", description: "\"SINK\"" },
peg$c71 = "SIG",
peg$c72 = { type: "literal", value: "SIG", description: "\"SIG\"" },
peg$c73 = "RT",
peg$c74 = { type: "literal", value: "RT", description: "\"RT\"" },
peg$c75 = "RRSIG",
peg$c76 = { type: "literal", value: "RRSIG", description: "\"RRSIG\"" },
peg$c77 = "RP",
peg$c78 = { type: "literal", value: "RP", description: "\"RP\"" },
peg$c79 = "RKEY",
peg$c80 = { type: "literal", value: "RKEY", description: "\"RKEY\"" },
peg$c81 = "PX",
peg$c82 = { type: "literal", value: "PX", description: "\"PX\"" },
peg$c83 = "PTR",
peg$c84 = { type: "literal", value: "PTR", description: "\"PTR\"" },
peg$c85 = "OPT",
peg$c86 = { type: "literal", value: "OPT", description: "\"OPT\"" },
peg$c87 = "OPENPGPKEY",
peg$c88 = { type: "literal", value: "OPENPGPKEY", description: "\"OPENPGPKEY\"" },
peg$c89 = "NXT",
peg$c90 = { type: "literal", value: "NXT", description: "\"NXT\"" },
peg$c91 = "NULL",
peg$c92 = { type: "literal", value: "NULL", description: "\"NULL\"" },
peg$c93 = "NSEC3PARAM",
peg$c94 = { type: "literal", value: "NSEC3PARAM", description: "\"NSEC3PARAM\"" },
peg$c95 = "NSEC3",
peg$c96 = { type: "literal", value: "NSEC3", description: "\"NSEC3\"" },
peg$c97 = "NSEC",
peg$c98 = { type: "literal", value: "NSEC", description: "\"NSEC\"" },
peg$c99 = "NSAP-PTR",
peg$c100 = { type: "literal", value: "NSAP-PTR", description: "\"NSAP-PTR\"" },
peg$c101 = "NSAP",
peg$c102 = { type: "literal", value: "NSAP", description: "\"NSAP\"" },
peg$c103 = "NINFO",
peg$c104 = { type: "literal", value: "NINFO", description: "\"NINFO\"" },
peg$c105 = "NIMLOC",
peg$c106 = { type: "literal", value: "NIMLOC", description: "\"NIMLOC\"" },
peg$c107 = "NID",
peg$c108 = { type: "literal", value: "NID", description: "\"NID\"" },
peg$c109 = "NAPTR",
peg$c110 = { type: "literal", value: "NAPTR", description: "\"NAPTR\"" },
peg$c111 = "MR",
peg$c112 = { type: "literal", value: "MR", description: "\"MR\"" },
peg$c113 = "MINFO",
peg$c114 = { type: "literal", value: "MINFO", description: "\"MINFO\"" },
peg$c115 = "MG",
peg$c116 = { type: "literal", value: "MG", description: "\"MG\"" },
peg$c117 = "MF",
peg$c118 = { type: "literal", value: "MF", description: "\"MF\"" },
peg$c119 = "MD",
peg$c120 = { type: "literal", value: "MD", description: "\"MD\"" },
peg$c121 = "MB",
peg$c122 = { type: "literal", value: "MB", description: "\"MB\"" },
peg$c123 = "MAILB",
peg$c124 = { type: "literal", value: "MAILB", description: "\"MAILB\"" },
peg$c125 = "MAILA",
peg$c126 = { type: "literal", value: "MAILA", description: "\"MAILA\"" },
peg$c127 = "LP",
peg$c128 = { type: "literal", value: "LP", description: "\"LP\"" },
peg$c129 = "LOC",
peg$c130 = { type: "literal", value: "LOC", description: "\"LOC\"" },
peg$c131 = "L64",
peg$c132 = { type: "literal", value: "L64", description: "\"L64\"" },
peg$c133 = "L32",
peg$c134 = { type: "literal", value: "L32", description: "\"L32\"" },
peg$c135 = "KX",
peg$c136 = { type: "literal", value: "KX", description: "\"KX\"" },
peg$c137 = "KEY",
peg$c138 = { type: "literal", value: "KEY", description: "\"KEY\"" },
peg$c139 = "IXFR",
peg$c140 = { type: "literal", value: "IXFR", description: "\"IXFR\"" },
peg$c141 = "ISDN",
peg$c142 = { type: "literal", value: "ISDN", description: "\"ISDN\"" },
peg$c143 = "IPSECKEY",
peg$c144 = { type: "literal", value: "IPSECKEY", description: "\"IPSECKEY\"" },
peg$c145 = "HIP",
peg$c146 = { type: "literal", value: "HIP", description: "\"HIP\"" },
peg$c147 = "HINFO",
peg$c148 = { type: "literal", value: "HINFO", description: "\"HINFO\"" },
peg$c149 = "GPOS",
peg$c150 = { type: "literal", value: "GPOS", description: "\"GPOS\"" },
peg$c151 = "GID",
peg$c152 = { type: "literal", value: "GID", description: "\"GID\"" },
peg$c153 = "EUI64",
peg$c154 = { type: "literal", value: "EUI64", description: "\"EUI64\"" },
peg$c155 = "EUI48",
peg$c156 = { type: "literal", value: "EUI48", description: "\"EUI48\"" },
peg$c157 = "EID",
peg$c158 = { type: "literal", value: "EID", description: "\"EID\"" },
peg$c159 = "DS",
peg$c160 = { type: "literal", value: "DS", description: "\"DS\"" },
peg$c161 = "DNSKEY",
peg$c162 = { type: "literal", value: "DNSKEY", description: "\"DNSKEY\"" },
peg$c163 = "DNAME",
peg$c164 = { type: "literal", value: "DNAME", description: "\"DNAME\"" },
peg$c165 = "DLV",
peg$c166 = { type: "literal", value: "DLV", description: "\"DLV\"" },
peg$c167 = "DHCID",
peg$c168 = { type: "literal", value: "DHCID", description: "\"DHCID\"" },
peg$c169 = "CSYNC",
peg$c170 = { type: "literal", value: "CSYNC", description: "\"CSYNC\"" },
peg$c171 = "CERT",
peg$c172 = { type: "literal", value: "CERT", description: "\"CERT\"" },
peg$c173 = "CDS",
peg$c174 = { type: "literal", value: "CDS", description: "\"CDS\"" },
peg$c175 = "CDNSKEY",
peg$c176 = { type: "literal", value: "CDNSKEY", description: "\"CDNSKEY\"" },
peg$c177 = "CAA",
peg$c178 = { type: "literal", value: "CAA", description: "\"CAA\"" },
peg$c179 = "AXFR",
peg$c180 = { type: "literal", value: "AXFR", description: "\"AXFR\"" },
peg$c181 = "ATMA",
peg$c182 = { type: "literal", value: "ATMA", description: "\"ATMA\"" },
peg$c183 = "APL",
peg$c184 = { type: "literal", value: "APL", description: "\"APL\"" },
peg$c185 = "AFSDB",
peg$c186 = { type: "literal", value: "AFSDB", description: "\"AFSDB\"" },
peg$c187 = "A6",
peg$c188 = { type: "literal", value: "A6", description: "\"A6\"" },
peg$c189 = { type: "any", description: "any character" },
peg$c190 = ".",
peg$c191 = { type: "literal", value: ".", description: "\".\"" },
peg$c192 = /^[a-z0-9\-_*]/i,
peg$c193 = { type: "class", value: "[a-z0-9-_\\*]i", description: "[a-z0-9-_\\*]i" },
peg$c194 = /^[smhdw]/i,
peg$c195 = { type: "class", value: "[smhdw]i", description: "[smhdw]i" },
peg$c196 = /^[0-9]/,
peg$c197 = { type: "class", value: "[0-9]", description: "[0-9]" },
peg$c198 = ":",
peg$c199 = { type: "literal", value: ":", description: "\":\"" },
peg$c200 = /^[0-9a-f]/i,
peg$c201 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },
peg$c202 = "0",
peg$c203 = { type: "literal", value: "0", description: "\"0\"" },
peg$c204 = /^[1-9]/,
peg$c205 = { type: "class", value: "[1-9]", description: "[1-9]" },
peg$c206 = { type: "other", description: "Comment" },
peg$c207 = ";",
peg$c208 = { type: "literal", value: ";", description: "\";\"" },
peg$c209 = function(message) { return message },
peg$c210 = { type: "other", description: "Newline" },
peg$c211 = "\n",
peg$c212 = { type: "literal", value: "\n", description: "\"\\n\"" },
peg$c213 = "\r\n",
peg$c214 = { type: "literal", value: "\r\n", description: "\"\\r\\n\"" },
peg$c215 = "\r",
peg$c216 = { type: "literal", value: "\r", description: "\"\\r\"" },
peg$c217 = "\u2028",
peg$c218 = { type: "literal", value: "\u2028", description: "\"\\u2028\"" },
peg$c219 = "\u2029",
peg$c220 = { type: "literal", value: "\u2029", description: "\"\\u2029\"" },
peg$c221 = { type: "other", description: "Whitespace or Newline" },
peg$c222 = { type: "other", description: "Whitespace" },
peg$c223 = /^[ \t]/,
peg$c224 = { type: "class", value: "[ \\t]", description: "[ \\t]" },
peg$c225 = "\"",
peg$c226 = { type: "literal", value: "\"", description: "\"\\\"\"" },
peg$c227 = /^[^"]/,
peg$c228 = { type: "class", value: "[^\"]", description: "[^\"]" },
peg$c229 = function(txt) { return txt },
peg$c230 = function(str) { return str },
peg$currPos = 0,
peg$savedPos = 0,
peg$posDetailsCache = [{ line: 1, column: 1, seenCR: false }],
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$result;
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
}
function text() {
return input.substring(peg$savedPos, peg$currPos);
}
function location() {
return peg$computeLocation(peg$savedPos, peg$currPos);
}
function expected(description) {
throw peg$buildException(
null,
[{ type: "other", description: description }],
input.substring(peg$savedPos, peg$currPos),
peg$computeLocation(peg$savedPos, peg$currPos)
);
}
function error(message) {
throw peg$buildException(
message,
null,
input.substring(peg$savedPos, peg$currPos),
peg$computeLocation(peg$savedPos, peg$currPos)
);
}
function peg$computePosDetails(pos) {
var details = peg$posDetailsCache[pos],
p, ch;
if (details) {
return details;
} else {
p = pos - 1;
while (!peg$posDetailsCache[p]) {
p--;
}
details = peg$posDetailsCache[p];
details = {
line: details.line,
column: details.column,
seenCR: details.seenCR
};
while (p < pos) {
ch = input.charAt(p);
if (ch === "\n") {
if (!details.seenCR) { details.line++; }
details.column = 1;
details.seenCR = false;
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
details.line++;
details.column = 1;
details.seenCR = true;
} else {
details.column++;
details.seenCR = false;
}
p++;
}
peg$posDetailsCache[pos] = details;
return details;
}
}
function peg$computeLocation(startPos, endPos) {
var startPosDetails = peg$computePosDetails(startPos),
endPosDetails = peg$computePosDetails(endPos);
return {
start: {
offset: startPos,
line: startPosDetails.line,
column: startPosDetails.column
},
end: {
offset: endPos,
line: endPosDetails.line,
column: endPosDetails.column
}
};
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) { return; }
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
peg$maxFailExpected = [];
}
peg$maxFailExpected.push(expected);
}
function peg$buildException(message, expected, found, location) {
function cleanupExpected(expected) {
var i = 1;
expected.sort(function(a, b) {
if (a.description < b.description) {
return -1;
} else if (a.description > b.description) {
return 1;
} else {
return 0;
}
});
while (i < expected.length) {
if (expected[i - 1] === expected[i]) {
expected.splice(i, 1);
} else {
i++;
}
}
}
function buildMessage(expected, found) {
function stringEscape(s) {
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
return s
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\x08/g, '\\b')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\f/g, '\\f')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
.replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
.replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
}
var expectedDescs = new Array(expected.length),
expectedDesc, foundDesc, i;
for (i = 0; i < expected.length; i++) {
expectedDescs[i] = expected[i].description;
}
expectedDesc = expected.length > 1
? expectedDescs.slice(0, -1).join(", ")
+ " or "
+ expectedDescs[expected.length - 1]
: expectedDescs[0];
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
return "Expected " + expectedDesc + " but " + foundDesc + " found.";
}
if (expected !== null) {
cleanupExpected(expected);
}
return new peg$SyntaxError(
message !== null ? message : buildMessage(expected, found),
expected,
found,
location
);
}
function peg$parseZonefile() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = [];
s2 = peg$parseDirective();
if (s2 === peg$FAILED) {
s2 = peg$parseEOL();
}
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = peg$parseDirective();
if (s2 === peg$FAILED) {
s2 = peg$parseEOL();
}
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseRecord();
if (s3 === peg$FAILED) {
s3 = peg$parseEOL();
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseRecord();
if (s3 === peg$FAILED) {
s3 = peg$parseEOL();
}
}
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c0(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseDirective() {
var s0;
s0 = peg$parseTtlDirective();
if (s0 === peg$FAILED) {
s0 = peg$parseOriginDirective();
}
return s0;
}
function peg$parseOriginDirective() {
var s0, s1, s2, s3, s4;
s0 = peg$currPos;
if (input.substr(peg$currPos, 7) === peg$c1) {
s1 = peg$c1;
peg$currPos += 7;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c2); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parseDomain();
if (s3 !== peg$FAILED) {
s4 = peg$parseEOL();
if (s4 === peg$FAILED) {
s4 = null;
}
if (s4 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c3(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseTtlDirective() {
var s0, s1, s2, s3, s4;
s0 = peg$currPos;
if (input.substr(peg$currPos, 4) === peg$c4) {
s1 = peg$c4;
peg$currPos += 4;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parseTime();
if (s3 !== peg$FAILED) {
s4 = peg$parseEOL();
if (s4 === peg$FAILED) {
s4 = null;
}
if (s4 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c6(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseRecord() {
var s0;
s0 = peg$parseARecord();
if (s0 === peg$FAILED) {
s0 = peg$parseAaaaRecord();
if (s0 === peg$FAILED) {
s0 = peg$parseCnameRecord();
if (s0 === peg$FAILED) {
s0 = peg$parseMxRecord();
if (s0 === peg$FAILED) {
s0 = peg$parseNsRecord();
if (s0 === peg$FAILED) {
s0 = peg$parseSrvRecord();
if (s0 === peg$FAILED) {
s0 = peg$parseSoaRecord();
if (s0 === peg$FAILED) {
s0 = peg$parseTxtRecord();
if (s0 === peg$FAILED) {
s0 = peg$parseGenericRecord();
}
}
}
}
}
}
}
}
return s0;
}
function peg$parseARecord() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseRecordIntro();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 65) {
s2 = peg$c7;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parse_();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseIpv4();
if (s4 !== peg$FAILED) {
s5 = peg$parse__();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c9(s1, s2, s4);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseAaaaRecord() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseRecordIntro();
if (s1 !== peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c10) {
s2 = peg$c10;
peg$currPos += 4;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parse_();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseIpv6();
if (s4 !== peg$FAILED) {
s5 = peg$parse__();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c9(s1, s2, s4);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseCnameRecord() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseRecordIntro();
if (s1 !== peg$FAILED) {
if (input.substr(peg$currPos, 5) === peg$c12) {
s2 = peg$c12;
peg$currPos += 5;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c13); }
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parse_();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseDomain();
if (s4 !== peg$FAILED) {
s5 = peg$parse__();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c14(s1, s2, s4);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseMxRecord() {
var s0, s1, s2, s3, s4, s5, s6, s7;
s0 = peg$currPos;
s1 = peg$parseRecordIntro();
if (s1 !== peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c15) {
s2 = peg$c15;
peg$currPos += 2;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c16); }
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parse_();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseInteger();
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parse_();
if (s6 !== peg$FAILED) {
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parse_();
}
} else {
s5 = peg$FAILED;
}
if (s5 !== peg$FAILED) {
s6 = peg$parseDomain();
if (s6 !== peg$FAILED) {
s7 = peg$parseEOL();
if (s7 === peg$FAILED) {
s7 = null;
}
if (s7 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c17(s1, s2, s4, s6);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseNsRecord() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseRecordIntro();
if (s1 !== peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c18) {
s2 = peg$c18;
peg$currPos += 2;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c19); }
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parse_();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseDomain();
if (s4 !== peg$FAILED) {
s5 = peg$parseEOL();
if (s5 === peg$FAILED) {
s5 = null;
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c20(s1, s2, s4);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseSoaRecord() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21;
s0 = peg$currPos;
s1 = peg$parseRecordIntro();
if (s1 !== peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c21) {
s2 = peg$c21;
peg$currPos += 3;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c22); }
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parse_();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseDomain();
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parse_();
if (s6 !== peg$FAILED) {
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parse_();
}
} else {
s5 = peg$FAILED;
}
if (s5 !== peg$FAILED) {
s6 = peg$parseDomain();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parse_();
if (s8 !== peg$FAILED) {
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parse_();
}
} else {
s7 = peg$FAILED;
}
if (s7 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 40) {
s8 = peg$c23;
peg$currPos++;
} else {
s8 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
if (s8 !== peg$FAILED) {
s9 = [];
s10 = peg$parse__();
if (s10 !== peg$FAILED) {
while (s10 !== peg$FAILED) {
s9.push(s10);
s10 = peg$parse__();
}
} else {
s9 = peg$FAILED;
}
if (s9 !== peg$FAILED) {
s10 = peg$parseInteger();
if (s10 !== peg$FAILED) {
s11 = [];
s12 = peg$parse__();
if (s12 !== peg$FAILED) {
while (s12 !== peg$FAILED) {
s11.push(s12);
s12 = peg$parse__();
}
} else {
s11 = peg$FAILED;
}
if (s11 !== peg$FAILED) {
s12 = peg$parseTime();
if (s12 !== peg$FAILED) {
s13 = [];
s14 = peg$parse__();
if (s14 !== peg$FAILED) {
while (s14 !== peg$FAILED) {
s13.push(s14);
s14 = peg$parse__();
}
} else {
s13 = peg$FAILED;
}
if (s13 !== peg$FAILED) {
s14 = peg$parseTime();
if (s14 !== peg$FAILED) {
s15 = [];
s16 = peg$parse__();
if (s16 !== peg$FAILED) {
while (s16 !== peg$FAILED) {
s15.push(s16);
s16 = peg$parse__();
}
} else {
s15 = peg$FAILED;
}
if (s15 !== peg$FAILED) {
s16 = peg$parseTime();
if (s16 !== peg$FAILED) {
s17 = [];
s18 = peg$parse__();
if (s18 !== peg$FAILED) {
while (s18 !== peg$FAILED) {
s17.push(s18);
s18 = peg$parse__();
}
} else {
s17 = peg$FAILED;
}
if (s17 !== peg$FAILED) {
s18 = peg$parseTime();
if (s18 !== peg$FAILED) {
s19 = [];
s20 = peg$parse__();
while (s20 !== peg$FAILED) {
s19.push(s20);
s20 = peg$parse__();
}
if (s19 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s20 = peg$c25;
peg$currPos++;
} else {
s20 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c26); }
}
if (s20 !== peg$FAILED) {
s21 = peg$parseEOL();
if (s21 === peg$FAILED) {
s21 = null;
}
if (s21 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c27(s1, s2, s4, s6, s10, s12, s14, s16, s18);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseSrvRecord() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
s0 = peg$currPos;
s1 = peg$parseRecordIntro();
if (s1 !== peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c28) {
s2 = peg$c28;
peg$currPos += 3;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c29); }
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parse_();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseInteger();
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parse_();
if (s6 !== peg$FAILED) {
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parse_();
}
} else {
s5 = peg$FAILED;
}
if (s5 !== peg$FAILED) {
s6 = peg$parseInteger();
if (s6 !== peg$FAILED) {
s7 = [];
s8 = peg$parse_();
if (s8 !== peg$FAILED) {
while (s8 !== peg$FAILED) {
s7.push(s8);
s8 = peg$parse_();
}
} else {
s7 = peg$FAILED;
}
if (s7 !== peg$FAILED) {
s8 = peg$parseInteger();
if (s8 !== peg$FAILED) {
s9 = [];
s10 = peg$parse_();
if (s10 !== peg$FAILED) {
while (s10 !== peg$FAILED) {
s9.push(s10);
s10 = peg$parse_();
}
} else {
s9 = peg$FAILED;
}
if (s9 !== peg$FAILED) {
s10 = peg$parseDomain();
if (s10 !== peg$FAILED) {
s11 = peg$parseEOL();
if (s11 === peg$FAILED) {
s11 = null;
}
if (s11 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c30(s1, s2, s4, s6, s8, s10);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseTxtRecord() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseRecordIntro();
if (s1 !== peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c31) {
s2 = peg$c31;
peg$currPos += 3;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c32); }
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parse_();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$parseStrings();
if (s5 !== peg$FAILED) {
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$parseStrings();
}
} else {
s4 = peg$FAILED;
}
if (s4 === peg$FAILED) {
s4 = peg$parseMultiLineStrings();
}
if (s4 !== peg$FAILED) {
s5 = peg$parseEOL();
if (s5 === peg$FAILED) {
s5 = null;
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c33(s1, s2, s4);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseGenericRecord() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseRecordIntro();
if (s1 !== peg$FAILED) {
s2 = peg$parseType();
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parse_();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseData();
if (s4 !== peg$FAILED) {
s5 = peg$parseEOL();
if (s5 === peg$FAILED) {
s5 = null;
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c34(s1, s2, s4);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseRecordIntro() {
var s0, s1, s2, s3, s4, s5, s6, s7;
s0 = peg$currPos;
s1 = peg$parseName(