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   1707 use feature ':5.10';
  33         59  
  33         2280  
3 33     33   177 use strict;
  33         61  
  33         549  
4 33     33   139 use warnings;
  33         55  
  33         7022  
5              
6 18     18 1 53 sub text { 'toomanyconn' }
7 4     4 0 12 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 786     786 1 3292 my $class = shift;
15 786   50     1639 my $argv1 = shift // return undef;
16              
17 786         1043 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 786 100       1351 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  11004         16017  
34 768         1723 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 712     712 0 1321 my $class = shift;
45 712   100     1711 my $argvs = shift // return undef;
46              
47 711 50       1504 return 1 if $argvs->reason eq 'toomanyconn';
48 711 50 100     3652 return 1 if (Sisimai::SMTP::Status->name($argvs->deliverystatus) || '') eq 'toomanyconn';
49 711 100       1684 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
50 696         1935 return 0;
51             }
52              
53             1;
54             __END__