Net::DNS::LivedoorDomain::DDNS - Update your livedoor DOMAIN (http://domain.livedoor.com/) DynamicDNS records.


Net-DNS-LivedoorDomain-DDNS documentation Contained in the Net-DNS-LivedoorDomain-DDNS distribution.

Index


Code Index:

NAME

Top

Net::DNS::LivedoorDomain::DDNS - Update your livedoor DOMAIN (http://domain.livedoor.com/) DynamicDNS records.

SYNOPSIS

Top

  use Net::DNS::LivedoorDomain::DDNS;
  my $ddns = Net::DNS::LivedoorDomain::DDNS->new;
  my $ret  = $ddns->update(
                           username => 'livedoorID',
                           password => '********',
                           hostname => 'www.example.com',
                           ip => '192.0.2.2',
                       );

METHODS

Top

new

Create a new Object.

update(%config)

Update your DynamicDNS record. %config parameters are:

username - livedoor Domain Dynamic DNS Password. (Required)

password - livedoor Domain Dynamic DNS Password. (Required)

hostname - Homain name being updated. (Required)

ip - The IP address to be updated. if empty, your current ip is used. (Optional)

DESCRIPTION

Top

This module help you to update your livedoor DOMAIN (http://domain.livedoor.com/) DynamicDNS record(s).

SEE ALSO

Top

http://domain.livedoor.com/

AUTHOR

Top

Masahito Yoshida <masahito@cpan.org>

COPYRIGHT AND LICENSE

Top


Net-DNS-LivedoorDomain-DDNS documentation Contained in the Net-DNS-LivedoorDomain-DDNS distribution.

package Net::DNS::LivedoorDomain::DDNS;

use strict;
use warnings;
use Carp;
use LWP::UserAgent;
use HTTP::Headers;
use HTTP::Request;
use Net::DNS::LivedoorDomain::DDNS::Response;

our $VERSION = '0.01';

use constant DDNS_URL => 'http://domain.livedoor.com/webapp/dice/update';

sub new {
    my ($class) = @_;
    my $self = bless {}, $class;
    $self;
}

sub update {
    my $self = shift;
    my %args = (
                username => undef,
                password => undef,
                hostname => undef,
                ip => undef,
                @_,
            );
    croak 'username is required' unless $args{username};
    croak 'password is required' unless $args{password};
    croak 'hostname is required' unless $args{hostname};

    my $header = HTTP::Headers->new;
    $header->authorization_basic($args{username}, $args{password});
    my $query = join '&',
        map { sprintf "%s=%s", $_, $args{$_} if defined $args{$_} }
            qw/hostname ip/;
    my $req = HTTP::Request->new('GET' => DDNS_URL .'?'. $query, $header);
    my $ua = LWP::UserAgent->new;
    my $res = $ua->request($req);
    return Net::DNS::LivedoorDomain::DDNS::Response->new($res);
}

1;

__END__