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 30     30   2703 use v5.26;
  30         110  
3 30     30   174 use strict;
  30         91  
  30         886  
4 30     30   144 use warnings;
  30         64  
  30         8319  
5              
6 3     3 1 8 sub text { 'networkerror' }
7 4     4 0 17 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 446     446 1 1399 my $class = shift;
15 446   100     1644 my $argv1 = shift // return 0;
16              
17 445         1163 state $index = [
18             "could not connect and send the mail to",
19             "dns records for the destination computer could not be found",
20             "host is unreachable",
21             "host name lookup failure",
22             "host not found, try again",
23             "maximum forwarding loop count exceeded",
24             "no route to host",
25             "too many hops",
26             "unable to resolve route ",
27             "unrouteable mail domain",
28             ];
29 445         806 state $pairs = [
30             ["malformed", "name server reply"],
31             ["mail ", "loop"],
32             ["message ", "loop"],
33             ];
34 445 100       1302 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  4450         8513  
35 417 100       961 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  1251         3025  
36 385         1272 return 0;
37             }
38              
39             sub true {
40             # The bounce reason is network error or not
41             # @param [Sisimai::Fact] argvs Object to be detected the reason
42             # @return [Integer] 1: is network error
43             # 0: is not network error
44             # @see http://www.ietf.org/rfc/rfc2822.txt
45 2     2 0 7 return 0;
46             }
47              
48             1;
49             __END__