I am affraid I do not exactly understand how you tested against a bind server. I also do not
understand what produces the output you provided with all the backslashes.
As for the new_from_hash method you want to use the char_str_list. Some example code is
below.
In order to show that this is wire compatible with BIND I set up a perl nameserver and use dig
to query it.
First the code:
------------------- cut ---------------------
#!/usr/local/bin/perl -Wall
use strict;
use warnings;
use Net::DNS::Nameserver;
my $nameserver=Net::DNS::Nameserver->new (
LocalAddr => "127.0.0.1",
LocalPort => 3553,
Verbose => 1,
ReplyHandler => \&reply_handler,
);
my $rr = Net::DNS::RR->new(
name => "foo.example.com",
ttl => 86400,
class => "IN",
type => "TXT",
char_str_list => ['bla',';'],
);
my $rr2=Net::DNS::RR->new('foo2.example.com 600 IN TXT "Test1 \" \; more stuff"
"Test2"');
$rr->print;
$rr2->print;
sub reply_handler {
my ($qname, $qclass, $qtype, $peerhost) = @_;
my ($rcode, @ans, @auth, @add);
if ($qtype eq "TXT" && $qname eq "foo.example.com") {
push @ans, $rr;
}elsif ($qtype eq "TXT" && $qname eq "foo2.example.com") {
push @ans, $rr;
} else {
$rcode = "SERFAIL";
}
return ($rcode, \@ans, \@auth, \@add, { aa => 1 });
}
$nameserver->main_loop;
---------------- cut ---------------------------------
And these are the queries that return exactly what I think should be returned
grover-Secret-Wg-org:~ olaf$ dig @127.0.0.1 -p 3553 foo.example.com TXT
; <<>> DiG 9.3.1 <<>> @127.0.0.1 -p 3553 foo.example.com TXT
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35736
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;foo.example.com. IN TXT
;; ANSWER SECTION:
foo.example.com. 86400 IN TXT "bla" "\;"
;; Query time: 197 msec
;; SERVER: 127.0.0.1#3553(127.0.0.1)
;; WHEN: Sat Nov 19 23:43:31 2005
;; MSG SIZE rcvd: 51
grover-Secret-Wg-org:~ olaf$ dig @127.0.0.1 -p 3553 foo2.example.com TXT
; <<>> DiG 9.3.1 <<>> @127.0.0.1 -p 3553 foo2.example.com TXT
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44794
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;foo2.example.com. IN TXT
;; ANSWER SECTION:
foo.example.com. 86400 IN TXT "bla" "\;"
;; Query time: 36 msec
;; SERVER: 127.0.0.1#3553(127.0.0.1)
;; WHEN: Sat Nov 19 23:43:37 2005
;; MSG SIZE rcvd: 56
I hope this helps...
--Olaf