| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::DNS::LivedoorDomain::DDNS; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
41435
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
75
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
48
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
182
|
|
|
6
|
2
|
|
|
2
|
|
1984
|
use LWP::UserAgent; |
|
|
2
|
|
|
|
|
95719
|
|
|
|
2
|
|
|
|
|
57
|
|
|
7
|
2
|
|
|
2
|
|
17
|
use HTTP::Headers; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
39
|
|
|
8
|
2
|
|
|
2
|
|
8
|
use HTTP::Request; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
37
|
|
|
9
|
2
|
|
|
2
|
|
1233
|
use Net::DNS::LivedoorDomain::DDNS::Response; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use constant DDNS_URL => 'http://domain.livedoor.com/webapp/dice/update'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
|
16
|
|
|
|
|
|
|
my ($class) = @_; |
|
17
|
|
|
|
|
|
|
my $self = bless {}, $class; |
|
18
|
|
|
|
|
|
|
$self; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub update { |
|
22
|
|
|
|
|
|
|
my $self = shift; |
|
23
|
|
|
|
|
|
|
my %args = ( |
|
24
|
|
|
|
|
|
|
username => undef, |
|
25
|
|
|
|
|
|
|
password => undef, |
|
26
|
|
|
|
|
|
|
hostname => undef, |
|
27
|
|
|
|
|
|
|
ip => undef, |
|
28
|
|
|
|
|
|
|
@_, |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
croak 'username is required' unless $args{username}; |
|
31
|
|
|
|
|
|
|
croak 'password is required' unless $args{password}; |
|
32
|
|
|
|
|
|
|
croak 'hostname is required' unless $args{hostname}; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $header = HTTP::Headers->new; |
|
35
|
|
|
|
|
|
|
$header->authorization_basic($args{username}, $args{password}); |
|
36
|
|
|
|
|
|
|
my $query = join '&', |
|
37
|
|
|
|
|
|
|
map { sprintf "%s=%s", $_, $args{$_} if defined $args{$_} } |
|
38
|
|
|
|
|
|
|
qw/hostname ip/; |
|
39
|
|
|
|
|
|
|
my $req = HTTP::Request->new('GET' => DDNS_URL .'?'. $query, $header); |
|
40
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
|
41
|
|
|
|
|
|
|
my $res = $ua->request($req); |
|
42
|
|
|
|
|
|
|
return Net::DNS::LivedoorDomain::DDNS::Response->new($res); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |