Hacker News new | comments | show | ask | jobs | submit login

A warning about parsing zone files... the grammar is deceptively tricky.

While TLD registries will probably provide you with files in a sane subset[0] of that specified in RFC 1035, there are a number of things that will NOT work in general:

- Splitting the file in to lines (paren-blocks and quoted strings can span lines, strings can contain ';' etc).

- Splitting the file on whitespace (it's significant in column 1 and inside strings)

- Applying a regex (you'll need lookahead for conditional matching and it'll get ugly fast)

Don't go down the road of assuming it's a simple delimited file.

A few references:

https://www.nlnetlabs.nl/projects/nsd/documentation.html

http://www.verycomputer.com/96_5ad11cc47053d8b0_1.htm

[0] See page 9 of https://archive.icann.org/en/topics/new-gtlds/zfa-strategy-p...




Yep.

I use the BIND tool named-compilezone to canonicalize zone files, which allows me to apply simple regex parsing, because I can assume one record per line, all fields present, and no abbreviated names. Main disadvantage is it is not very fast.


It's probably slow because by default it does a bunch of DNS queries to foreign zones to see if your NS records etc are good.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: