# HG changeset patch # User Heiko Schlittermann # Date 1471039308 -7200 # Node ID 140d7537105e65d7d41209b7078d3c31f43e9665 # Parent 9069ce49fd83b962062081637137d62bbf17a99e Moved to git@git.schlittermann.de:dnsvi.git diff -r 9069ce49fd83 -r 140d7537105e Build.PL --- a/Build.PL Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -use Module::Build; - -Module::Build->new( - dist_name => 'dnsvi', - dist_version_from => 'bin/dnsvi', - dist_abstract => 'simple script to edit dynamic DNS zones', - script_files => ['bin/dnsvi'], - requires => { - perl => 5.010, - 'Term::ReadKey' => '0', - 'Net::DNS' => '0.66', - } -)->create_build_script; diff -r 9069ce49fd83 -r 140d7537105e INSTALL --- a/INSTALL Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -Build ------ - - perl Build.PL - ./Build - ./Build test - -Install -------- - - ./Build fakeinstall - ./Build install - -And now have fun :) diff -r 9069ce49fd83 -r 140d7537105e MANIFEST --- a/MANIFEST Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -.hgignore -.hgsigs -.hgtags -bin/dnsvi -Build.PL -debian/changelog -debian/compat -debian/control -debian/copyright -debian/rules -debian/source/format -INSTALL -lib/DNS/Vi.pm -MANIFEST This list of files -t/10-dnsvi.t -t/20-cname-change.t -t/20-reverse-dns.t -t/samples/a -t/samples/axfr -t/samples/b -t/samples/c -t/samples/d -t/samples/frey-1 -t/samples/frey-2 diff -r 9069ce49fd83 -r 140d7537105e MANIFEST.SKIP --- a/MANIFEST.SKIP Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ - -#!start included /home/heiko/perl5/lib/perl5/ExtUtils/MANIFEST.SKIP -# Avoid version control files. -\bRCS\b -\bCVS\b -\bSCCS\b -,v$ -\B\.svn\b -\B\.git\b -\B\.gitignore\b -\b_darcs\b -\B\.cvsignore$ - -# Avoid VMS specific MakeMaker generated files -\bDescrip.MMS$ -\bDESCRIP.MMS$ -\bdescrip.mms$ - -# Avoid Makemaker generated and utility files. -\bMANIFEST\.bak -\bMakefile$ -\bblib/ -\bMakeMaker-\d -\bpm_to_blib\.ts$ -\bpm_to_blib$ -\bblibdirs\.ts$ # 6.18 through 6.25 generated this - -# Avoid Module::Build generated and utility files. -\bBuild$ -\b_build/ -\bBuild.bat$ -\bBuild.COM$ -\bBUILD.COM$ -\bbuild.com$ - -# Avoid temp and backup files. -~$ -\.old$ -\#$ -\b\.# -\.bak$ -\.tmp$ -\.# -\.rej$ - -# Avoid OS-specific files/dirs -# Mac OSX metadata -\B\.DS_Store -# Mac OSX SMB mount metadata files -\B\._ - -# Avoid Devel::Cover and Devel::CoverX::Covered files. -\bcover_db\b -\bcovered\b - -# Avoid MYMETA files -^MYMETA\. -#!end included /home/heiko/perl5/lib/perl5/ExtUtils/MANIFEST.SKIP - -# Avoid configuration metadata file -^MYMETA\. - -# Avoid Module::Build generated and utility files. -\bBuild$ -\bBuild.bat$ -\b_build -\bBuild.COM$ -\bBUILD.COM$ -\bbuild.com$ -^MANIFEST\.SKIP - -# Avoid archives of this distribution -\bdnsvi-[\d\.\_]+ - -\bK.* -^\.hg/ -^debian/dnsvi.* -^debian/files -^CHANGES$ diff -r 9069ce49fd83 -r 140d7537105e README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Sat Aug 13 00:01:48 2016 +0200 @@ -0,0 +1,1 @@ +see https://git.schlittermann.de/cgit/dnsvi diff -r 9069ce49fd83 -r 140d7537105e bin/dnsvi --- a/bin/dnsvi Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,244 +0,0 @@ -#! /usr/bin/perl -#line 3 -# Copyright: (C) 2014-2015 Heiko Schlittermann -# This program is released unter the Terms of the GPL. -use 5.10.1; -use strict; -use warnings; -use if $ENV{DEBUG} => 'Smart::Comments'; -use Getopt::Long; -use Pod::Usage; -use File::Copy; -use DNS::Vi; -use if $] >= 5.020, experimental => 'smartmatch'; - -our $VERSION = '1.0'; - -sub slurp { - local $/ = undef; - local @ARGV = @_; - <>; -} - -sub main { - my %o = ( - local => undef, - key => (grep { -f } glob "$ENV{HOME}/.dnsvi/default/K*key")[0] - // (undef, local => 1), - server => undef, - debug => undef, - editor => $ENV{EDITOR} // 'vi', - skip => [qw/RRSIG NSEC3 NSEC3PARAM NSEC DNSKEY TSIG/], - ); - - GetOptions( - 'k|key=s' => \$o{key}, - 's|server=s' => \$o{server}, - 'd|debug!' => \$o{debug}, - 'l|local!' => \$o{local}, - 'editor=s' => \$o{editor}, - ) - && @ARGV >= 1 - or pod2usage(); - - - my %auth = get_auth_info shift @ARGV, $o{server}; - my $zone = $auth{name}; - - $o{server} = $o{local} ? 'localhost' : $auth{mname} - if not defined $o{server}; - - my @dig = ( - dig => 'AXFR', - defined $o{key} ? (-k => $o{key}) : (), - defined $o{server} ? ("\@$o{server}") : (), - $zone - ); - - my @zone1 = parse($_ = `@dig`, { -skip => $o{skip} }) - or die "Empty zone\n"; - - UNDO: - my @zone2 = @zone1; - my $backup; # it's a tmp file containing the original - - EDIT: - @zone2 = do { - if (my $file = shift @ARGV) { - parse(slurp($file), { -skip => $o{skip} }); - } - else { - edit( - @zone2, - { - -skip => $o{skip}, - -editor => $o{editor}, - -backup => \$backup - } - ); - } - }; - ### @zone2 - - my %delta = delta(\@zone1, \@zone2); - if (!%delta) { - say 'nothing changed'; - return 0; - } - - VIEW: - if ($_ eq 'v' or (map { @{$_} } values %delta) < 10) { - say 'The following changes need your confirmation.'; - say join "\n", show(@delta{qw/add del/}); - } - else { - say 'added: ', 0 + @{ $delta{add} }, ', removed: ', - 0 + @{ $delta{del} }; - } - CONFIRM: - print 'action [yqQvVeu?] ?'; - $_ = get_key; - - given ($_) { - when ('y') { } - when ('q') { } - when ('V') { } - when ('Q') { return 1 } - when ('e') { goto EDIT } - when ('v') { goto VIEW } - when ('u') { goto UNDO } - when ('?') { - print <<_; - y -- yes: submit changes and exit - q -- quit: save changes as ",dnsvi-$$" - Q -- quit: discard changes and exit - v -- view changes - V -- view changes as nsupdate commands - e -- edit again - u -- undo and edit again - ? -- what? -_ - goto CONFIRM; - } - default { goto CONFIRM } - } - - /^[yV]$/ and update( - \@zone1, - @delta{qw/add del/}, - { - $_ eq 'V' ? (-dry => 1) : (), - -server => $o{server}, - -local => $o{local}, - -debug => $o{debug}, - -key => $o{key} - } - ) - or do { - if ($backup) { - copy($backup->filename, ",dnsvi-$$") - and say "Saved as ',dnsvi-$$'"; - } - }; - - goto CONFIRM if $_ eq 'V'; - - return 0; -} - -exit main(@ARGV) if not caller; - -__END__ - -=head1 NAME - - dnsvi -- editor for dynamically maintained zones - -=head1 SYNOPSIS - - dnsvi [[-l] | [[-k key] [-s server]]] [-d] [] - -=head1 DESCRIPTION - -This tools supports you in maintaining a dynamic zone. Normally you'll -use it with the name of zone. For batch mode you may use it with an -additional parameter, die edited zone file. - -=head2 OPTIONS - -=over - -=item B<-l>|B<--local> - -Local mode, when running on the server where the updates need to go to. -But still zone transfers need to be enabled! (default: on, if not -default key file is found, otherwise off) - -=item B<-s>|B<--server> B - -The name of the server to contact for the AXFR and the update. -(default: main nameserver from the SOA record) - -=item B<-k>|B<--key> B - -The name of the key file we need for TSIG (the AXFR will use it, -as well as the update). (default: F<~/.dnsvi/default/K*key) - -To create such a key you may use - - dnssec-keygen -a HMAC-MD5 -b 512 -n USER heiko - -Then copy the resulting files somewhere (you'll need both files). -On the server side include the key into to configuration: - - key "" { - algorithm HMAC-MD5; - secret "" - }; - -Per zone you should use - - zone "" { - ... - update-policy { - grant local-ddns zonesub any; // support for -l - grant zonesub; // support for -k - }; - ... - }; - -=item B<-d> - -This option enables debugging of C. (default: off) - -=back - -=head1 EXAMPLES - -The usage is quite straight forward: - - dnsvi example.com - dnsvi sub.sub.sub.example.com - dnsvi 212.80.235.130 - -If something went wrong and you need to re-open your backup: - - dnsvi example.com ,dnsvi-815 - -=head1 PREREQUISITES - -We need some tools to be installed: - -=over - -=item B - -The domain information groper is used for the zone transfer currently. - -=item B - -The nsupdate tool is used to send the updates back to the server. - -=back - -=cut diff -r 9069ce49fd83 -r 140d7537105e debian/changelog --- a/debian/changelog Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -dnsvi (1.3) stable; urgency=medium - - * Use user supplied server for get_auth_info too - - -- Heiko Schlittermann (HS12-RIPE) Thu, 14 Jul 2016 10:30:52 +0200 - -dnsvi (1.2) stable; urgency=medium - - * better regex for removing the comments: - - -- Heiko Schlittermann (HS12-RIPE) Thu, 09 Apr 2015 22:07:03 +0200 - -dnsvi (1.1) stable; urgency=medium - - * less verbose for dh_make: - * add tw=0 at the very end of the zone file: - * sort for comparison! - * Added test for DKIM TXT record: - * allow ; in ".." lines: - - -- Heiko Schlittermann (HS12-RIPE) Thu, 09 Apr 2015 13:55:47 +0200 - -dnsvi (1.0) stable; urgency=medium - - * Now we can edit reverse zones!: - * [perltidy]: - * updated dependeny on Net::DNS: - * updated the info about needed files: - * skip the CHANGES file: - * put the depencies there: - * more docu: - - -- Heiko Schlittermann (HS12-RIPE) Wed, 28 Jan 2015 23:55:06 +0100 - -dnsvi (0.10) stable; urgency=medium - - * fixed mising backup after reloading a ,dnsvi* file: - - -- Heiko Schlittermann (HS12-RIPE) Wed, 28 Jan 2015 12:51:11 +0100 - -dnsvi (0.9) stable; urgency=medium - - * really, no experimental in bin/dnsvi: - - -- Heiko Schlittermann (HS12-RIPE) Tue, 27 Jan 2015 22:07:10 +0100 - -dnsvi (0.8) stable; urgency=medium - - * use smartmatch experimental if >=5.20: - - -- Heiko Schlittermann (HS12-RIPE) Tue, 27 Jan 2015 22:04:58 +0100 - -dnsvi (0.7) stable; urgency=medium - - * use default -k … and -l …: check $HOME/.dnsvi/default/K*key, - otherwise use -l - * added more option to confirmation dialog: - - -- Heiko Schlittermann (HS12-RIPE) Tue, 27 Jan 2015 21:55:33 +0100 - -dnsvi (0.6) stable; urgency=medium - - * more tests: - * [merged] from branch deb: - * sort order in a more prominent place: Now we have a %ORDER global - variable in the package DNS::Vi - * fixed trailing spaces: - * cope with additional spaces in soa records: - * cope with continuation lines: - * deal with very short primary names in SOA record: - * changed the delta function: Now it returns a hash, not an array. - * cosmetical changes: - * fixed the cname change bug (reported by m.f.): - * Hint about the SOA record: - - -- Heiko Schlittermann (HS12-RIPE) Wed, 21 Jan 2015 23:09:39 +0100 - -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) Mon, 08 Dec 2014 10:23:43 +0100 - -dnsvi (0.4) stable; urgency=low - - * section added - - -- Heiko Schlittermann (HS12-RIPE) 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) Fri, 14 Nov 2014 10:55:39 +0100 - -dnsvi (0.2) stable; urgency=low - - * fixed manifesto: - * fixed the manifesto again: - * [savepoint]: - * built the first packate for tests: - * fixed lintian warning about standards version: - - -- Heiko Schlittermann (HS12-RIPE) Fri, 14 Nov 2014 09:59:58 +0100 - -dnsvi (0.1) stable; urgency=low - - * bug fix release - - -- Heiko Schlittermann (HS12-RIPE) Thu, 13 Nov 2014 23:05:31 +0100 - -dnsvi (0.0) stable; urgency=low - - * Initial release. - - -- Heiko Schlittermann (HS12-RIPE) Thu, 05 Jun 2014 21:09:29 +0200 diff -r 9069ce49fd83 -r 140d7537105e debian/compat --- a/debian/compat Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -9 diff -r 9069ce49fd83 -r 140d7537105e debian/control --- a/debian/control Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -Source: dnsvi -Build-Depends: debhelper (>= 9) -Maintainer: Heiko Schlittermann (HS12-RIPE) -Standards-Version: 3.9.4 -Section: admin -Priority: standard - -Package: dnsvi -Architecture: all -Section: admin -Priority: standard -Depends: perl (>= 5.14), dnsutils, libnet-dns-perl, libterm-readkey-perl -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. diff -r 9069ce49fd83 -r 140d7537105e debian/copyright --- a/debian/copyright Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -Copyright (C) 2014 Heiko Schlittermann - -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. - diff -r 9069ce49fd83 -r 140d7537105e debian/rules --- a/debian/rules Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -#! /usr/bin/make -f - -export PERL_MM_OPT = -export PERL_MB_OPT = -export PERL5LIB = - -#export DH_VERBOSE = 1 - -%: - dh $@ - -override_dh_installchangelogs: - dh_installchangelogs CHANGES diff -r 9069ce49fd83 -r 140d7537105e debian/source/format --- a/debian/source/format Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -3.0 (native) diff -r 9069ce49fd83 -r 140d7537105e lib/DNS/Vi.pm --- a/lib/DNS/Vi.pm Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,317 +0,0 @@ -package DNS::Vi; -use 5.0101; -use strict; -use warnings; -use if $ENV{DEBUG} // '' eq 'dnsvi' => 'Smart::Comments'; -use Digest::SHA qw(sha512_hex); -use File::Temp; -use Net::DNS; -use Term::ReadKey; -use base 'Exporter'; -use if $] >= 5.020, experimental => 'smartmatch'; - -our @EXPORT = qw(ttl2h h2ttl parse delta nice edit update show get_key - get_auth_info); -our @EXPORT_OK = (); - -# the sort order for the records of the same label -my %ORDER = map { state $n = 0; $_ => ++$n } qw(SOA NS TXT MX A AAAA SSHFP); - -sub h2ttl(_); - -# input $arg - hash with options -# $data - a long string with the zone data -sub parse { - my %arg = %{ pop @_ } if ref $_[-1] eq ref {}; - my $data = shift; - my @lines = split /\n/, $data; - - my @zone; - my ($origin, $ttl, $last_label, $soa_seen); - - $_ = ''; - foreach (@lines) { - # simplificated comment remover - # after the comment character no '"' is allowed! -# s{^\s*;.*$}{}; # strip comment lines -# s{\s*;[^"]*$}{}; # strip trailing comments - - # see https://regex101.com/r/cG6fK3/2 - s{\s*(?:;)(?:(?:[^"]|"[^"]*")*$)}{}; - state $line; - if (my $range = /(.*)\(\s*$/ .. /(.*)\)\s*/) { - $line .= defined $1 ? $1 : $_; - next unless $range =~ /E0$/; - } - if (defined $line) { - $_ = $line; # accumulated continuation line - $line = undef; - } - s{\s*$}{}; # strip off trailing spaces - given ($_) { - when (m{^\s*$}) { next } - when (m{^\s*\$ORIGIN\s+(\S+)}) { $origin = $1 } - when (m{^\s*\$TTL\s+(\S+)}) { $ttl = $1 } - when ( - m{^(?:(?