3
0

démon un peu plus simple, message d'erreur si pas d'IP trouvée

This commit is contained in:
karchnu 2015-12-29 00:15:20 +01:00
parent c7fa0c08f6
commit 78cf8306a9

View File

@ -30,20 +30,15 @@ our $type = 'A'; # could be AAAA
our $cacert = "ca.cert"; our $cacert = "ca.cert";
sub get_ip { sub get_ip {
my @tmp_ip = split "\n", `wget -nv -O - $checkip`; for (split "\n", `wget -nv -O - $checkip`) {
my $ip; /^[0-9.]+$/ || /^[0-9a-f:]+$/ and return $_
for(@tmp_ip) {
if($_ =~ /^[0-9.]+$/ || $_ =~ /^[0-9a-f:]+$/) {
$ip = $_;
} }
} undef
$ip;
} }
sub update { sub update {
my $ip = get_ip; my $ip = get_ip;
die "Can't get your IP address !" unless $ip;
say "UPDATE :: domain $name.$domain => IP $ip, type $type"; say "UPDATE :: domain $name.$domain => IP $ip, type $type";
my $passb64 = encode_base64($pass); my $passb64 = encode_base64($pass);