File Coverage

lib/Sisimai/Reason/TooManyConn.pm
Criterion Covered Total %
statement 23 23 100.0
branch 6 8 75.0
condition 5 6 83.3
subroutine 7 7 100.0
pod 2 4 50.0
total 43 48 89.5


line stmt bran cond sub pod time code
1             package Sisimai::Reason::TooManyConn;
2 33     33   2149 use feature ':5.10';
  33         68  
  33         2659  
3 33     33   213 use strict;
  33         63  
  33         640  
4 33     33   167 use warnings;
  33         70  
  33         8913  
5              
6 8     8 1 32 sub text { 'toomanyconn' }
7 4     4 0 16 sub description { 'SMTP connection rejected temporarily due to too many concurrency connections to the remote host' }
8             sub match {
9             # Try to match that the given text and regular expressions
10             # @param [String] argv1 String to be matched with regular expressions
11             # @return [Integer] 0: Did not match
12             # 1: Matched
13             # @since v4.1.26
14 766     766 1 3855 my $class = shift;
15 766   50     1551 my $argv1 = shift // return undef;
16              
17 766         1231 state $index = [
18             'all available ips are at maximum connection limit', # SendGrid
19             'connection rate limit exceeded',
20             'exceeds per-domain connection limit for',
21             'has exceeded the max emails per hour ',
22             'throttling failure: daily message quota exceeded',
23             'throttling failure: maximum sending rate exceeded',
24             'too many connections',
25             'too many connections from your host.', # Microsoft
26             'too many concurrent smtp connections', # Microsoft
27             'too many errors from your ip', # Free.fr
28             'too many recipients', # ntt docomo
29             'too many smtp sessions for this host', # Sendmail(daemon.c)
30             'trop de connexions, ',
31             'we have already made numerous attempts to deliver this message',
32             ];
33 766 100       1375 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  10724         18172  
34 758         1796 return 0;
35             }
36              
37             sub true {
38             # Blocked due to that connection rate limit exceeded
39             # @param [Sisimai::Data] argvs Object to be detected the reason
40             # @return [Integer] 1: Too many connections(blocked)
41             # 0: Not many connections
42             # @since v4.1.26
43             # @see http://www.ietf.org/rfc/rfc2822.txt
44 692     692 0 1123 my $class = shift;
45 692   100     1641 my $argvs = shift // return undef;
46              
47 691 50       1670 return 1 if $argvs->reason eq 'toomanyconn';
48 691 50 100     3701 return 1 if (Sisimai::SMTP::Status->name($argvs->deliverystatus) || '') eq 'toomanyconn';
49 691 100       1740 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
50 686         1862 return 0;
51             }
52              
53             1;
54             __END__