2014-08-23 11:32:26 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use v5.14;
|
|
|
|
|
2015-12-28 01:29:24 +01:00
|
|
|
use MIME::Base64 qw(encode_base64);
|
|
|
|
|
2015-12-22 22:33:23 +01:00
|
|
|
# the website sending your current IP address
|
|
|
|
our $checkip = "http://t.karchnu.fr/ip.php";
|
|
|
|
|
|
|
|
# Domain name of the service provider (like netlib.re)
|
|
|
|
our $nddservice = "netlib.re";
|
|
|
|
|
|
|
|
# Your domain
|
|
|
|
our $domain = "test.netlib.re";
|
|
|
|
|
|
|
|
# Login and password to connect to the website
|
|
|
|
our $login = "idtest";
|
|
|
|
our $pass = "mdptest";
|
|
|
|
|
|
|
|
# Your entry to change
|
2015-12-28 16:08:52 +01:00
|
|
|
#
|
|
|
|
# here, the entry is www.test.netlib.re
|
|
|
|
# put "@" in $name to change your $type record on $domain directly
|
|
|
|
our $name = 'www';
|
2015-12-22 22:33:23 +01:00
|
|
|
our $type = 'A'; # could be AAAA
|
|
|
|
|
|
|
|
# The CA certificate, to authenticate the website (should be provided)
|
|
|
|
# Check your service provider for updates
|
|
|
|
our $cacert = "ca.cert";
|
2014-08-23 11:32:26 +02:00
|
|
|
|
|
|
|
sub get_ip {
|
2015-12-22 22:33:23 +01:00
|
|
|
my @tmp_ip = split "\n", `wget -nv -O - $checkip`;
|
2014-08-23 11:32:26 +02:00
|
|
|
my $ip;
|
|
|
|
|
|
|
|
for(@tmp_ip) {
|
|
|
|
if($_ =~ /^[0-9.]+$/ || $_ =~ /^[0-9a-f:]+$/) {
|
|
|
|
$ip = $_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$ip;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub update {
|
|
|
|
my $ip = get_ip;
|
|
|
|
|
2015-12-22 22:33:23 +01:00
|
|
|
say "UPDATE :: domain $name.$domain => IP $ip, type $type";
|
2015-12-28 01:29:24 +01:00
|
|
|
my $passb64 = encode_base64($pass);
|
|
|
|
chomp $passb64;
|
2014-08-23 11:32:26 +02:00
|
|
|
|
2015-12-22 22:33:23 +01:00
|
|
|
my $cmd = "wget -O - ";
|
|
|
|
$cmd .=
|
2015-12-28 01:29:24 +01:00
|
|
|
"https://$nddservice/domain/cliup/$login/$passb64/$domain/$name/$type/$ip ";
|
2015-12-22 22:33:23 +01:00
|
|
|
$cmd .= "--ca-certificate=$cacert";
|
2015-12-28 01:29:24 +01:00
|
|
|
say "CMD :: $cmd";
|
|
|
|
`$cmd`;
|
2014-08-23 11:32:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
update;
|