App-DDNS-Namecheap

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    App::DDNS::Namecheap - Dynamic DNS update utility for Namecheap
    registered domains

VERSION
    version 0.014

SYNOPSIS
        my $domain =  App::DDNS::Namecheap->new(
                          domain   => 'mysite.org',
                          password => 'abcdefghijklmnopqrstuvwxyz012345',
                          hosts    => [ "@", "www", "*" ],
                          ip       => '127.0.0.1',    #optional -- defaults to external ip
        );

        $domain->update();

DESCRIPTION
    This module provides a method for setting the address records of your
    Namecheap hosted domains.

lib/App/DDNS/Namecheap.pm  view on Meta::CPAN

{
  $App::DDNS::Namecheap::VERSION = '0.014';
}

use Moose;
use LWP::Simple qw($ua get);
$ua->agent("");
use Mozilla::CA;

has domain => ( is => 'ro', isa => 'Str', required => 1 );
has password => ( is => 'ro', isa => 'Str', required => 1 );
has hosts => ( is => 'ro', isa => 'ArrayRef', required => 1 );
has ip => ( is => 'ro', isa => 'Str', required => 0 );

sub update {
  my $self = shift;
  foreach ( @{ $self->{hosts} } ) {
    my $url = "https://dynamicdns.park-your-domain.com/update?domain=$self->{domain}&password=$self->{password}&host=$_";
    $url .= "&ip=$self->{ip}" if $self->{ip};
    if ( my $return = get($url) ) {
      unless ( $return =~ /<errcount>0<\/errcount>/is ) {
	$return = ( $return =~ /<responsestring>(.*)<\/responsestring>/is ? $1 : "unknown error" );
        print "failure submitting host \"$_\.$self->{domain}\": $return\n";
	return;
      }
    }
  }
}

lib/App/DDNS/Namecheap.pm  view on Meta::CPAN

App::DDNS::Namecheap - Dynamic DNS update utility for Namecheap registered domains

=head1 VERSION

version 0.014

=head1 SYNOPSIS

    my $domain =  App::DDNS::Namecheap->new(
                      domain   => 'mysite.org',
         	      password => 'abcdefghijklmnopqrstuvwxyz012345',
		      hosts    => [ "@", "www", "*" ],
                      ip       => '127.0.0.1',    #optional -- defaults to external ip
    );

    $domain->update();

=head1 DESCRIPTION

This module provides a method for setting the address records of your Namecheap hosted 
domains. 

scripts/update.pl  view on Meta::CPAN

use strict;
use warnings;

use App::DDNS::Namecheap;

my $timeout = 24;  # 24 hour timeout
$timeout *= 3600;

my $domain =  App::DDNS::Namecheap->new(
                domain   => 'mysite.org',
          	password => 'abcdefghijklmnopqrstuvwxyz012345',
		hosts    => [ "@", "www", "*" ],
);

while (1) {
  $domain->update();
  sleep ($timeout);
}

1;

t/1.t  view on Meta::CPAN

use Data::Dumper;

use Test::More tests => 8;

use lib "../lib/";
use App::DDNS::Namecheap;

my $domain = 'mysite.org';
my $password = 'abcdefghijklmnopqrstuvwxyz123456';
my $hosts = [ '@', 'www', '*' ];
my $ip = '127.0.0.1';

my $update = App::DDNS::Namecheap->new( domain => $domain, password => $password, hosts => $hosts );
ok( defined $update );
ok( $update->isa('App::DDNS::Namecheap'));

$update = App::DDNS::Namecheap->new( domain => $domain, password => $password, hosts => $hosts, ip => $ip );
ok( defined $update );

ok( $update->isa('App::DDNS::Namecheap'));
ok( $update->{domain} eq $domain );
ok( $update->{password} eq $password );
ok( $update->{hosts} ~~ $hosts );
ok( $update->{ip} eq $ip );



( run in 0.971 second using v1.01-cache-2.11-cpan-49f99fa48dc )