From dd45d2fdda9849fbbf435e1289d5a9fd2b1bd10a Mon Sep 17 00:00:00 2001 From: Jorj Bauer Date: Mon, 22 Feb 2016 12:18:11 -0500 Subject: [PATCH] added custom types --- Makefile.PL | 3 +++ bin/add-custom | 19 +++++++++++++++++++ bin/del-custom | 14 ++++++++++++++ bin/list-custom | 12 ++++++++++++ 4 files changed, 48 insertions(+) create mode 100755 bin/add-custom create mode 100755 bin/del-custom create mode 100755 bin/list-custom diff --git a/Makefile.PL b/Makefile.PL index 0efe96a..fd44aaf 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -14,6 +14,9 @@ WriteMakefile( 'bin/add-slave', 'bin/del-slave', 'bin/list-slaves', + 'bin/add-custom', + 'bin/del-custom', + 'bin/list-custom', ], 'AUTHOR' => 'Jorj Bauer ', ); diff --git a/bin/add-custom b/bin/add-custom new file mode 100755 index 0000000..68eaa50 --- /dev/null +++ b/bin/add-custom @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Martnet::DDNS; +use Regexp::Common qw/net/; + +my $host = shift || die "No zonename provided"; +my $master = shift || die "No master DNS IP provided"; + +die "Zonename must end in a dot" + unless ($host =~ /^[a-zA-Z0-9\.\-\_]+\.$/); + +my $regex = $RE{net}{IPv4} . '|' . $RE{net}{IPv6}; +die "Master must be an IPv4 or IPv6 address" + unless ($master =~ /^$regex$/); + +my $ddns = Martnet::DDNS->new(); +$ddns->add($host, $master, '_custom'); diff --git a/bin/del-custom b/bin/del-custom new file mode 100755 index 0000000..b7123dd --- /dev/null +++ b/bin/del-custom @@ -0,0 +1,14 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Martnet::DDNS; +use Regexp::Common qw/net/; + +my $host = shift || die "No zonename provided"; + +die "Zonename must end in a dot" + unless ($host =~ /^[a-zA-Z0-9\-\_\.]+\.$/); + +my $ddns = Martnet::DDNS->new(); +$ddns->del($host, '_custom'); diff --git a/bin/list-custom b/bin/list-custom new file mode 100755 index 0000000..7156e04 --- /dev/null +++ b/bin/list-custom @@ -0,0 +1,12 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Martnet::DDNS; + +my $ddns = Martnet::DDNS->new(); + +my @vh = $ddns->get('_custom'); +foreach my $i (sort {$a->{zone} cmp $b->{zone}} @vh) { + print $i->{zone}, ". master: ", $i->{master},"\n"; +}