line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package SRS::EPP::Command::Renew::Domain; |
3
|
|
|
|
|
|
|
{ |
4
|
|
|
|
|
|
|
$SRS::EPP::Command::Renew::Domain::VERSION = '0.22'; |
5
|
|
|
|
|
|
|
} |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4916
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
8
|
|
|
|
|
|
|
extends 'SRS::EPP::Command::Renew'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
9926
|
use MooseX::Params::Validate; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
11
|
1
|
|
|
1
|
|
635
|
use SRS::EPP::Session; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use XML::EPP::Domain; |
13
|
|
|
|
|
|
|
use XML::SRS::TimeStamp; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# for plugin system to connect |
16
|
|
|
|
|
|
|
sub xmlns { |
17
|
|
|
|
|
|
|
XML::EPP::Domain::Node::xmlns(); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use MooseX::TimestampTZ qw(epoch); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub dates_approx_match { |
23
|
|
|
|
|
|
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my ( $domain_date, $txn_date ) = pos_validated_list( |
26
|
|
|
|
|
|
|
\@_, |
27
|
|
|
|
|
|
|
{ isa => 'XML::SRS::TimeStamp' }, |
28
|
|
|
|
|
|
|
{ isa => 'Str' }, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $domain_epoch = $domain_date->epoch(); |
33
|
|
|
|
|
|
|
my $txn_epoch = epoch "$txn_date 00:00:00Z"; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $diff = $domain_epoch - $txn_epoch; |
36
|
|
|
|
|
|
|
return abs($diff) < (86400*2); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub process { |
40
|
|
|
|
|
|
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my ( $session ) = pos_validated_list( |
43
|
|
|
|
|
|
|
\@_, |
44
|
|
|
|
|
|
|
{ isa => 'SRS::EPP::Session' }, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$self->session($session); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $epp = $self->message; |
50
|
|
|
|
|
|
|
my $message = $epp->message; |
51
|
|
|
|
|
|
|
my $payload = $message->argument->payload; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$session->stalled($self); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return XML::SRS::Whois->new( |
56
|
|
|
|
|
|
|
domain => $payload->name(), |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has 'billed_until' => |
61
|
|
|
|
|
|
|
is => "rw", |
62
|
|
|
|
|
|
|
isa => "XML::SRS::TimeStamp", |
63
|
|
|
|
|
|
|
; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub notify { |
66
|
|
|
|
|
|
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my ( $rs ) = pos_validated_list( |
69
|
|
|
|
|
|
|
\@_, |
70
|
|
|
|
|
|
|
{ isa => 'ArrayRef[SRS::EPP::SRSResponse]' }, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $epp = $self->message; |
74
|
|
|
|
|
|
|
my $eppMessage = $epp->message; |
75
|
|
|
|
|
|
|
my $eppPayload = $eppMessage->argument->payload; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $message = $rs->[0]->message; |
78
|
|
|
|
|
|
|
my $response = $message->response or goto error_out; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
if ( !$self->billed_until() ) { |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# This must be a response to our query TXN |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
if ( $response->status eq "Available" ) { |
85
|
|
|
|
|
|
|
return $self->make_response( |
86
|
|
|
|
|
|
|
code => 2303, |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
my $billed_until = $response->billed_until |
90
|
|
|
|
|
|
|
or goto error_out; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if ( |
93
|
|
|
|
|
|
|
!$self->dates_approx_match( |
94
|
|
|
|
|
|
|
$billed_until, |
95
|
|
|
|
|
|
|
$eppPayload->expiry_date, |
96
|
|
|
|
|
|
|
) |
97
|
|
|
|
|
|
|
) |
98
|
|
|
|
|
|
|
{ |
99
|
|
|
|
|
|
|
my $current = $billed_until->date; |
100
|
|
|
|
|
|
|
my $reason = "Not close enough to current " |
101
|
|
|
|
|
|
|
."expiry date ($current)"; |
102
|
|
|
|
|
|
|
return $self->make_error( |
103
|
|
|
|
|
|
|
code => 2304, |
104
|
|
|
|
|
|
|
value => $eppPayload->expiry_date, |
105
|
|
|
|
|
|
|
reason => $reason, |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
$self->billed_until( $response->billed_until() ); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
$self->session->stalled(0); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
return XML::SRS::Domain::Update->new( |
114
|
|
|
|
|
|
|
filter => [$response->name], |
115
|
|
|
|
|
|
|
action_id => $self->client_id || $self->server_id, |
116
|
|
|
|
|
|
|
renew => 1, |
117
|
|
|
|
|
|
|
term => $eppPayload->period->months, |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# By now, we must be dealing with the response to our update TXN |
122
|
|
|
|
|
|
|
if ( $response->can("billed_until") ) { |
123
|
|
|
|
|
|
|
my $epp_resp = XML::EPP::Domain::Renew::Response->new( |
124
|
|
|
|
|
|
|
name => $response->name, |
125
|
|
|
|
|
|
|
expiry_date => $response->billed_until->timestamptz, |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
return $self->make_response( |
128
|
|
|
|
|
|
|
code => 1000, |
129
|
|
|
|
|
|
|
payload => $epp_resp, |
130
|
|
|
|
|
|
|
); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
error_out: |
134
|
|
|
|
|
|
|
return $self->make_response(code => 2400); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |