File Coverage

lib/Sisimai/Reason/NetworkError.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition 2 2 100.0
subroutine 7 7 100.0
pod 2 4 50.0
total 35 37 94.5


line stmt bran cond sub pod time code
1             package Sisimai::Reason::NetworkError;
2 38     38   2626 use v5.26;
  38         140  
3 38     38   148 use strict;
  38         54  
  38         766  
4 38     38   126 use warnings;
  38         56  
  38         9298  
5              
6 3     3 1 9 sub text { 'networkerror' }
7 4     4 0 15 sub description { 'SMTP connection failed due to DNS look up failure or other network problems' }
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.12
14 581     581 1 1586 my $class = shift;
15 581   100     2825 my $argv1 = shift // return 0;
16              
17 580         829 state $index = [
18             "address family mismatch on destination mxs", # OpenSMTPD/smtpd/mta.c
19             "all routes to destination blocked", # OpenSMTPD/smtpd/mta.c
20             "bad dns lookup error code", # OpenSMTPD/smtpd/mta.c
21             "could not connect and send the mail to",
22             "could not contact dns servers",
23             "could not retrieve source address", # OpenSMTPD/smtpd/mta.c
24             "dns records for the destination computer could not be found",
25             "establish an smtp connection",
26             "exceeded maximum hop count", # Courier
27             "host is unreachable",
28             "host name lookup failure",
29             "host not found, try again",
30             "listed as a best-preference mx",
31             "loop detected", # OpenSMTPD/smtpd/mta.c
32             "maximum forwarding loop count exceeded",
33             "network error on destination mxs", # OpenSMTPD/smtpd/mta.c
34             "no relevant answers",
35             "temporary failure in mx lookup", # OpenSMTPD/smtpd/mta.c
36             "too many hops",
37             "unable to resolve route ",
38             "unrouteable mail domain",
39             ];
40 580         706 state $pairs = [
41             ["malformed", "name server reply"],
42             ["mail ", "loop"],
43             ["message ", "loop"],
44             ["no ", "route to"],
45             ];
46 580 100       998 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  12180         14606  
47 542 100       909 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  2168         3139  
48 505         1109 return 0;
49             }
50              
51             sub true {
52             # The bounce reason is network error or not
53             # @param [Sisimai::Fact] argvs Object to be detected the reason
54             # @return [Integer] 1: is network error
55             # 0: is not network error
56             # @see http://www.ietf.org/rfc/rfc2822.txt
57 2     2 0 10 return 0;
58             }
59              
60             1;
61             __END__