line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ACME::RetryAfter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
4
|
|
|
|
|
|
|
# A base class for modules that handle the 202 status with Retry-After |
5
|
|
|
|
|
|
|
# header, as described in the ACME protocol spec. |
6
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
7
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
2872
|
use strict; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
204
|
|
9
|
7
|
|
|
7
|
|
33
|
use warnings; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
160
|
|
10
|
|
|
|
|
|
|
|
11
|
7
|
|
|
7
|
|
844
|
use Net::ACME::HTTP (); |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
2653
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
8
|
|
|
8
|
0
|
6416
|
my ( $class, %opts ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
8
|
50
|
|
|
|
42
|
my $uri = $opts{'uri'} or do { |
17
|
0
|
|
|
|
|
0
|
die( sprintf "“%s” requires a “uri”!", __PACKAGE__ ); |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
8
|
|
|
|
|
27
|
my $self = bless { _uri => $uri }, $class; |
21
|
|
|
|
|
|
|
|
22
|
8
|
100
|
|
|
|
27
|
if ( $opts{'retry_after'} ) { |
23
|
4
|
|
|
|
|
20
|
$self->_consume_retry_after_value( $opts{'retry_after'} ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
8
|
|
|
|
|
38
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
3
|
0
|
21
|
sub uri { return (shift)->{'_uri'}; } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub is_time_to_poll { |
32
|
9
|
|
|
9
|
0
|
4001855
|
my ($self) = @_; |
33
|
|
|
|
|
|
|
|
34
|
9
|
|
|
|
|
32
|
my $earliest_time = $self->{'_next_retry_time'}; |
35
|
|
|
|
|
|
|
|
36
|
9
|
100
|
100
|
|
|
103
|
return 1 if !$earliest_time || ( time >= $earliest_time ); |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
25
|
return 0; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub poll { |
42
|
10
|
|
|
10
|
0
|
890
|
my ($self) = @_; |
43
|
|
|
|
|
|
|
|
44
|
10
|
|
|
|
|
43
|
my $resp = $self->_http_get( $self->{'_uri'} ); |
45
|
|
|
|
|
|
|
|
46
|
10
|
100
|
|
|
|
1470
|
if ( $resp->status() == 202 ) { |
47
|
3
|
|
|
|
|
49
|
$self->_consume_retry_after_value( $resp->header('retry-after') ); |
48
|
3
|
|
|
|
|
20
|
return undef; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
7
|
|
|
|
|
130
|
return scalar $self->_handle_non_202_poll($resp); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#https://ietf-wg-acme.github.io/acme/#certificate-issuance |
55
|
|
|
|
|
|
|
sub _consume_retry_after_value { |
56
|
7
|
|
|
7
|
|
57
|
my ( $self, $val ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
7
|
|
33
|
|
|
41
|
$self->{'_next_retry_time'} = $val && ( time + $val ); |
59
|
|
|
|
|
|
|
|
60
|
7
|
|
|
|
|
14
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _http_get { |
64
|
10
|
|
|
10
|
|
23
|
my ( $self, $uri ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
10
|
|
66
|
|
|
74
|
$self->{'_http'} ||= Net::ACME::HTTP->new(); |
67
|
|
|
|
|
|
|
|
68
|
10
|
|
|
|
|
38
|
return $self->{'_http'}->get($uri); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |