--- a/.hgtags Wed Jan 14 01:46:06 2015 +0100
+++ b/.hgtags Wed Jan 14 08:57:54 2015 +0100
@@ -2,3 +2,6 @@
87fbca9dbdcc85eec83c9da1ee178ff146420e0f dns-vi_0.1
ece524aeadc16a71503fd67e2c1644b354f65347 dnsvi_0.1
b69b8513e61f71ae2316db95f11602e38eb6d1f8 dnsvi_0.2
+1c0d34fb18361825a27bcd0f322e9c72fcdca6ae dnsvi_0.3
+d889aa5a141964683cd42c0668d48a955e3da1e9 dnsvi_0.4
+6009102dd52992bb0cca856522d36fa73652afa5 dnsvi_0.5
--- a/MANIFEST Wed Jan 14 01:46:06 2015 +0100
+++ b/MANIFEST Wed Jan 14 08:57:54 2015 +0100
@@ -15,3 +15,4 @@
t/samples/axfr
t/samples/b
t/samples/c
+debian/copyright
--- a/debian/changelog Wed Jan 14 01:46:06 2015 +0100
+++ b/debian/changelog Wed Jan 14 08:57:54 2015 +0100
@@ -1,3 +1,26 @@
+dnsvi (0.5) stable; urgency=low
+
+ * Changed the sort order.: When displaying the zone we sort in a way
+ where same domains are kept together with their subdomains. We do
+ this by reverting the label and sorting these reverted labels.
+
+ -- Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de> Mon, 08 Dec 2014 10:23:43 +0100
+
+dnsvi (0.4) stable; urgency=low
+
+ * section added
+
+ -- Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de> Fri, 14 Nov 2014 11:41:25 +0100
+
+dnsvi (0.3) stable; urgency=low
+
+ * [merged] from debian:
+ * ignore CHANGES:
+ * extended description
+ * added the copyright
+
+ -- Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de> Fri, 14 Nov 2014 10:55:39 +0100
+
dnsvi (0.2) stable; urgency=low
* fixed manifesto:
--- a/debian/control Wed Jan 14 01:46:06 2015 +0100
+++ b/debian/control Wed Jan 14 08:57:54 2015 +0100
@@ -1,7 +1,9 @@
Source: dnsvi
Build-Depends: debhelper (>= 9)
-Maintainer: Heiko Schlittermann <hs@schlittermann.de>
+Maintainer: Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Standards-Version: 3.9.4
+Section: admin
+Priority: standard
Package: dnsvi
Architecture: all
@@ -9,3 +11,6 @@
Priority: standard
Depends: perl (>= 5.14), dnsutils
Description: DNS (domain) zone editor
+ This tools allows you edit a dynamically maintained DNS zone,
+ either locally or remote. The update of the zone is done via
+ nsupdate, secured by TSIG.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/copyright Wed Jan 14 08:57:54 2015 +0100
@@ -0,0 +1,18 @@
+Copyright (C) 2014 Heiko Schlittermann <hs@schlittermann.de>
+
+This program is free software; you may redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This is distributed in the hope that it will be useful, but without
+any warranty; without even the implied warranty of merchantability or
+fitness for a particular purpose. See the GNU General Public License
+for more details.
+
+A copy of the GNU General Public License version 3 is available as
+/usr/share/common-licenses/GPL-3 in the Debian GNU/Linux distribution
+or at http://www.gnu.org/licenses/old-licenses/gpl-3.0.html.
+You can also obtain it by writing to the Free Software Foundation, Inc.,
+51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
--- a/lib/DNS/Vi.pm Wed Jan 14 01:46:06 2015 +0100
+++ b/lib/DNS/Vi.pm Wed Jan 14 08:57:54 2015 +0100
@@ -2,19 +2,20 @@
use 5.010;
use strict;
use warnings;
-use if $ENV{DEBUG}//'' eq 'dnsvi' => 'Smart::Comments';
+use if $ENV{DEBUG} // '' eq 'dnsvi' => 'Smart::Comments';
use Digest::SHA qw(sha512_hex);
use File::Temp;
use base 'Exporter';
no if $^V ge v5.16.0 => (warnings => 'experimental');
+
#no if $warnings::Offset{'experimental'} => (warnings => 'experimental');
-our @EXPORT = qw(ttl2h h2ttl parse delta nice edit update show);
+our @EXPORT = qw(ttl2h h2ttl parse delta nice edit update show);
our @EXPORT_OK = ();
sub parse {
- my %arg = %{pop @_} if ref $_[-1] eq 'HASH';
- my $data = shift;
+ my %arg = %{ pop @_ } if ref $_[-1] eq 'HASH';
+ my $data = shift;
my @lines = split /\n/, $data;
my @zone;
@@ -45,7 +46,7 @@
rrtype => uc $+{rrtype},
data => $+{data},
);
- next if $rrset{rrtype} ~~ $arg{-skip};
+ next if $rrset{rrtype} ~~ $arg{-skip};
if ($rrset{rrtype} eq 'SOA') {
next if $soa_seen;
@@ -71,7 +72,7 @@
# bei einigen RRs müssen wir die Daten korrigieren
when ([qw/CNAME MX NS PTR SOA/]) {
- $rrset{data} =~ s/\@/$origin/g;
+ $rrset{data} =~ s/\@/$origin/g;
$rrset{data} .= ".$origin"
unless substr($rrset{data}, -1) eq '.';
}
@@ -123,49 +124,56 @@
}
{
- my %order = map { state $n = 0; $_ => ++$n } qw(SOA NS TXT MX A AAAA);
-sub nice {
+ my %order = map { state $n = 0; $_ => ++$n } qw(SOA NS TXT MX A AAAA SSHFP);
- # get a list of { id => $id, rrset => \%rrset }
- my @zone =
- sort {
- length $a->{label} <=> length $b->{label}
- or $a->{label} cmp $b->{label}
- or ($order{$a->{rrtype}}//99) <=> ($order{$b->{rrtype}}//99)
- } map { $_->{rrset} } @_;
+ sub nice {
- my @out;
- my $origin = (grep { $_->{rrtype} eq 'SOA' } @zone)[0]->{label};
- my $ttl = (grep { $_->{rrtype} eq 'SOA' } @zone)[0]->{ttl};
- my $len1 = (sort { $a <=> $b } map { index $_->{label}, '.' } @zone)[-1];
- my $len2 = (sort { $a <=> $b } map { length $_->{rrtype} } @zone)[-1];
- push @out, "\$ORIGIN $origin", "\$TTL " . ttl2h($ttl);
+ # get a list of { id => $id, rrset => \%rrset }
+ # we do a schwartz transformation here
+ # [ reverse LABEL, RRSET ]
+ my @zone = map { $_->[1] }
+ sort {
+ $a->[0] cmp $b->[0]
+ or length $a->[1]{label} <=> length $b->[1]{label}
+ or ($order{ $a->[1]{rrtype} } // 99) <=> ($order{ $b->[1]{rrtype} } // 99)
+ }
+ map { [scalar reverse($_->{label}), $_] } map { $_->{rrset} } @_;
- my $print = sub {
- my %r = %{ +shift };
- state $last_label;
+ my @out;
+ my $origin = (grep { $_->{rrtype} eq 'SOA' } @zone)[0]->{label};
+ my $ttl = (grep { $_->{rrtype} eq 'SOA' } @zone)[0]->{ttl};
+ my $len1 =
+ (sort { $a <=> $b } map { index $_->{label}, '.' } @zone)[-1];
+ my $len2 = (sort { $a <=> $b } map { length $_->{rrtype} } @zone)[-1];
+ push @out, "\$ORIGIN $origin", "\$TTL " . ttl2h($ttl);
- $r{label} = '@' if $r{label} eq $origin;
- $r{label} =~ s{\.\Q$origin\E$}{};
- $r{data} =~ s{\.\Q$origin\E$}{} if $r{rrtype} ~~ [qw(CNAME MX SOA PTR)];
- $r{data} =~ s{\Q$origin\E$}{\@} if $r{rrtype} ~~ [qw(CNAME MX)];
- $r{ttl} = $r{ttl} == $ttl ? '' : ttl2h($r{ttl});
- $r{label} = do {
- if (defined $last_label and $r{label} eq $last_label) { '' }
- else { $last_label = $r{label} }
- };
+ my $print = sub {
+ my %r = %{ +shift };
+ state $last_label;
- return sprintf '%-*s %6s %-*s %s',
- $len1 => $r{label},
- $r{ttl},
- $len2 => $r{rrtype},
- $r{data};
- };
- push @out, '; do NOT EDIT the SOA records SERIAL number!';
- push @out, $print->($_) foreach @zone;
- return join "\n", @out, '';
+ $r{label} = '@' if $r{label} eq $origin;
+ $r{label} =~ s{\.\Q$origin\E$}{};
+ $r{data} =~ s{\.\Q$origin\E$}{}
+ if $r{rrtype} ~~ [qw(CNAME MX SOA PTR)];
+ $r{data} =~ s{\Q$origin\E$}{\@} if $r{rrtype} ~~ [qw(CNAME MX)];
+ $r{ttl} = $r{ttl} == $ttl ? '' : ttl2h($r{ttl});
+ $r{label} = do {
+ if (defined $last_label and $r{label} eq $last_label) { '' }
+ else { $last_label = $r{label} }
+ };
+
+ return sprintf '%-*s %6s %-*s %s',
+ $len1 => $r{label},
+ $r{ttl},
+ $len2 => $r{rrtype},
+ $r{data};
+ };
+ push @out, '; do NOT EDIT the SOA records SERIAL number!';
+ push @out, $print->($_) foreach @zone;
+ return join "\n", @out, '';
+ }
}
-}
+
sub delta {
my ($zone1, $zone2) = @_;
my %zone1 = map { $_->{id}, $_->{rrset} } @$zone1;
@@ -183,7 +191,7 @@
}
sub edit {
- my %arg = %{pop @_} if ref $_[-1] eq 'HASH';
+ my %arg = %{ pop @_ } if ref $_[-1] eq 'HASH';
my @zone = @_;
my $tmp = File::Temp->new();
@@ -191,21 +199,18 @@
$tmp->flush();
system $arg{-editor} => $tmp->filename;
$tmp->seek(0, 0);
- ${$arg{-backup}} = $tmp if $arg{-backup};
- return parse(do { local $/ = undef; <$tmp>}, {-skip => $arg{-skip}});
+ ${ $arg{-backup} } = $tmp if $arg{-backup};
+ return parse(do { local $/ = undef; <$tmp> }, { -skip => $arg{-skip} });
}
sub show {
my ($add, $del) = @_;
- my @out = (
- (map { " - $_ " } @$del),
- (map { " + $_ " } @$add),
- );
+ my @out = ((map { " - $_ " } @$del), (map { " + $_ " } @$add),);
return @out;
}
sub update {
- my %arg = %{pop @_} if ref $_[-1] eq 'HASH';
+ my %arg = %{ pop @_ } if ref $_[-1] eq 'HASH';
my ($zone1, $add, $del) = @_;
my $orig_soa =
@@ -242,7 +247,7 @@
open(my $fh, '>', $file) or die "Can't open >$file: $!\n";
print $fh nice @$zone;
close($fh);
-
+
}
1;