3
0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
dnsmanagerv1/cli/daemon/daemon.pl

60 lines
1.1 KiB
Perl
Raw Normal View History

2014-08-23 11:32:26 +02:00
#!/usr/bin/perl -w
use strict;
use warnings;
use v5.14;
our $ndd = "netlib.re";
our $domain = "montest.netlib.re";
our $name = "www";
our $ttl = "3600";
our $login = "test";
our $pass = "test";
sub get_ip {
my @tmp_ip = split "\n", `wget -nv -O - http://t.karchnu.fr/ip.php`;
my $ip;
for(@tmp_ip) {
if($_ =~ /^[0-9.]+$/ || $_ =~ /^[0-9a-f:]+$/) {
$ip = $_;
}
}
$ip;
}
sub update {
my $ip = get_ip;
my $type;
if($ip =~ /:/) {
$type = "AAAA";
}
else {
$type = "A";
}
my $todig;
if($name =~ '@') {
$todig = $domain;
}
else {
$todig = "$name.$domain";
}
my $oldhost = `dig +short $todig`;
chomp $oldhost;
say "domain $domain";
say "name $name";
say "type $type";
say "oldhost $oldhost";
say "ttl $ttl";
say "ip $ip";
#say "wget -O - https://$ndd/domain/cli/$login/$pass/$domain/$name/$type/$oldhost/$ttl/$ip --ca-certificate=ca.cert";
say `wget -O - https://$ndd/domain/cli/$login/$pass/$domain/$name/$type/$oldhost/$ttl/$ip --ca-certificate=ca.cert`;
}
update;