def RR.new_from_string(rrstring)
rrstring.gsub!(/(\?<!\\);.*/o, "");
if ((rrstring =~/#{@@RR_REGEX}/xo) == nil)
raise Exception, "#{rrstring} did not match RR pat.\nPlease report this to the author!\n"
end
name = $1;
ttl = $2.to_i || 0;
rrclass = $3 || '';
rrtype = $4 || '';
rdata = $5 || '';
if rdata
rdata.gsub!(/\s+$/o, "")
end
if rrtype =~/^TYPE\d+/o
rrtype = Dnsruby::Types.typesbyval(Dnsruby::Types::typesbyname(rrtype))
end
if rrclass =~/^CLASS\d+/o
rrclass = Dnsruby::Classes.classesbyval(Dnsruby::Classes::classesbyname(rrclass))
end
if (rrtype=='' && rrclass && rrclass == 'ANY')
rrtype = 'ANY';
rrclass = 'IN';
elsif (rrclass=='')
rrclass = 'IN';
end
if (rrtype == '')
rrtype = 'ANY';
end
if (implemented_rrs.include?(rrtype) && rdata !~/^\s*\\#/o )
subclass = _get_subclass(name, rrtype, rrclass, ttl, rdata)
return subclass
elsif (implemented_rrs.include?(rrtype))
rdata =~ /\\\#\s+(\d+)\s+(.*)$/o;
rdlength = $1.to_i;
hexdump = $2;
hexdump.gsub!(/\s*/, "");
if hexdump.length() != rdlength*2
raise Exception, "#{rdata} is inconsistent; length does not match content"
end
rdata = [hexdump].pack('H*');
return new_from_data(name, rrtype, rrclass, ttl, rdlength, rdata, 0)
elsif (rdata=~/\s*\\\#\s+\d+\s+/o)
raise Exception, 'Expected RFC3597 representation of RDATA' unless rdata =~/\\\#\s+(\d+)\s+(.*)$/o;
rdlength = $1.to_i;
hexdump = $2;
hexdump.gsub!(/\s*/o, "");
if hexdump.length() != rdlength*2
raise Exception, "#{rdata} is inconsistent; length does not match content" ;
end
rdata = [hexdump].pack('H*');
return new_from_data(name,rrtype,rrclass,ttl,rdlength,rdata,0)
else
subclass = _get_subclass(name, rrtype, rrclass, ttl, "")
return subclass
end
end