aeden / dns-zonefile Goto Github PK
View Code? Open in Web Editor NEWWorking with zonefiles (RFC 1035 section 5 and RFC 1034 section 3.6.1) in Ruby
License: Do What The F*ck You Want To Public License
Working with zonefiles (RFC 1035 section 5 and RFC 1034 section 3.6.1) in Ruby
License: Do What The F*ck You Want To Public License
When I load the gem, I get the following error:
$ pry
[1] pry(main)> require "dns/zonefile"
Errno::ENOENT: No such file or directory @ rb_sysopen - lib/dns/zonefile.treetop
from /Users/kerry/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/treetop-1.6.5/lib/treetop/compiler/grammar_compiler.rb:37:in `initialize'
It looks like this is a load path issue, as if I edit the gem source to expand the full path of zonefile.treetop
the error disappears.
Is it possible to remove parser.rb from source control since it is a generated file? It is very hard to apply upstream changes, or supply clean, sensible PRs, with potential conflicts in this generated file.
After upgrading to 1.1.3 I'm getting the following output every time I require the gem in ruby 2.3.1. As far as I can tell it's a treetop related issue:
rb(main):001:0> require "dns/zonefile"
Extraneous module ignored with nested atomic: "(\n host space ms_age ttl klass \"CNAME\" space target:host /\n host space klass ms_age ttl \"CNAME\" space target:host /\n host space ms_age ttl \"CNAME\" space target:host /\n host space klass \"CNAME\" space target:host \n ) {\n def to_s\n \"\#{host} \#{ttl} \#{klass} CNAME \#{target}\"\n end\n\n def record_type\n \"CNAME\"\n end\n }"
Extraneous module ignored with nested atomic: "(\n host space ms_age ttl klass \"SRV\" space priority:integer space weight:integer space port:integer space target:host /\n host space klass ms_age ttl \"SRV\" space priority:integer space weight:integer space port:integer space target:host /\n host space ms_age ttl \"SRV\" space priority:integer space weight:integer space port:integer space target:host /\n host space klass \"SRV\" space priority:integer space weight:integer space port:integer space target:host\n ) {\n def to_s\n \"\#{host} \#{ttl} \#{klass} SRV \#{priority} \#{weight} \#{port} \#{target}\"\n end\n\n def record_type\n \"SRV\"\n end\n }"
Extraneous module ignored with nested atomic: "((\"IN\" space) / '') {\n def to_s\n text_value.strip\n end\n }"
Extraneous module ignored with nested atomic: "( \"[AGE:\" [\\d]+ \"]\" space / '' ) {\n def to_s\n text_value\n end\n }"
Extraneous module ignored with nested atomic: "((time_interval space) / '') {\n def to_i\n respond_to?(:time_interval) ? time_interval.to_i : nil\n end\n def to_s\n respond_to?(:time_interval) ? time_interval.to_s : ''\n end\n }"
Extraneous module ignored with nested atomic: "(\n \"(\" space* data:txt_data space* \")\" /\n data:txt_data\n ) {\n def to_s\n data.to_s\n end\n }"
Extraneous module ignored with nested atomic: "( '\"' ( '\\\"' / [^\"] )* '\"') {\n def to_s\n text_value\n end\n }"
Hi,
Trying to parse a DNS zonefile as created by exporting from Microsoft DNS server.
It fails on the following parts.
Short of requesting this to be fixed since it might not conform to the RFC standards noted, is there any way we could make the parser ignore lines that do not conform.
Line:
_nfsv4idmapdomain 86400 TXT ( "some.domain.com" )
Failure:
DNS::Zonefile::ParsingError: Expected one of [ \t], '"', [a-zA-Z0-9] at line 35, column 35 (byte 1237) after _nfsv4idmapdomain 86400 TXT
Line:
hostname001 [AGE:3636591] 1200 A 10.195.200.240
Failure:
DNS::Zonefile::ParsingError: Expected one of [ \t], [0-9], "IN", "A", "AAAA", "CNAME", "MX", "NAPTR", "NS", "PTR", "SRV", "SPF", "TXT", ";", "SOA" at line 2844, column 25 (byte 114536) after hostname001
We experienced a weird parsing issue with a normally OK bind zonefile.
The parser expects a SOA record right after the $ORIGIN
definition, but it's not always work.
I've a following zone:
$ORIGIN .
$TTL 3600 ; 1 hour
192.168.2.1 IN A 192.168.2.1
router.domain.com A 192.168.2.1
mydomain.com SOA ns.domain.com. hostmaster.domain.com. (
26 ; serial
900 ; refresh (15 minutes)
600 ; retry (10 minutes)
86400 ; expire (1 day)
3600 ; minimum (1 hour)
)
And it works totally fine with Bind but DNS::Zonefile fails to parse it.
The TODO contains this entry.
Does anyone have thoughts on what it'd take to do this? I've not really put any energy into it yet, but just wanted to check if anyone had thoughts/notes?
According to RFC 1035:
<character-string> is a single
length octet followed by that number of characters. <character-string>
is treated as binary information, and can be up to 256 characters in
length (including the length octet).
and
<character-string> is expressed in one or two ways: as a contiguous set
of characters without interior spaces, or as a string beginning with a "
and ending with a ". Inside a " delimited string any character can
occur, except for a " itself, which must be quoted using \ (back slash).
Therefore unquoted TXT data should be treated as the first contiguous character string of 1 to 255 characters following the TXT type declaration, and quoted TXT data should be treated as any contiguous character string of 1 to 255 characters, inside quotes.
At the moment unquoted TXT is limited to a regular expression that still includes many allowable characters, which should instead be changed to allow any non whitespace, however trying to make this change currently breaks the spec.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.