| 1 | package Sisimai::Rhost; | ||||||||||||
| 2 | 86 | ▶ | use v5.26; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 86 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 86 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 86 | state $RhostClass = { | |||||||||||
| 7 | "Aol" => [".mail.aol.com", ".mx.aol.com"], | ||||||||||||
| 8 | "Apple" => [".mail.icloud.com", ".apple.com", ".me.com", "privaterelay.appleid.com"], | ||||||||||||
| 9 | "Cloudflare" => [".mx.cloudflare.net"], | ||||||||||||
| 10 | "Cox" => ["cox.net"], | ||||||||||||
| 11 | "Facebook" => [".facebook.com"], | ||||||||||||
| 12 | "FrancePTT" => [".laposte.net", ".orange.fr", ".wanadoo.fr"], | ||||||||||||
| 13 | "GoDaddy" => ["smtp.secureserver.net", "mailstore1.secureserver.net"], | ||||||||||||
| 14 | "Google" => ["aspmx.l.google.com", "gmail-smtp-in.l.google.com"], | ||||||||||||
| 15 | "GSuite" => ["googlemail.com"], | ||||||||||||
| 16 | "IUA" => [".email.ua"], | ||||||||||||
| 17 | "KDDI" => [".ezweb.ne.jp", "msmx.au.com"], | ||||||||||||
| 18 | "MessageLabs" => [".messagelabs.com"], | ||||||||||||
| 19 | "Microsoft" => [".prod.outlook.com", ".protection.outlook.com", ".onmicrosoft.com", ".exchangelabs.com",], | ||||||||||||
| 20 | "Mimecast" => [".mimecast.com"], | ||||||||||||
| 21 | "NTTDOCOMO" => ["mfsmax.docomo.ne.jp"], | ||||||||||||
| 22 | "Outlook" => [".hotmail.com"], | ||||||||||||
| 23 | "Spectrum" => ["charter.net"], | ||||||||||||
| 24 | "Tencent" => [".qq.com"], | ||||||||||||
| 25 | "YahooInc" => [".yahoodns.net"], | ||||||||||||
| 26 | "Zoho" => [".zoho.com", ".zoho.eu", ".zoho.jp", ".zoho.com.au", ".zoho.com.cn", ".zoho.in"], | ||||||||||||
| 27 | }; | ||||||||||||
| 28 | |||||||||||||
| 29 | 3425 | ▶ | sub name { | ||||||||||
|
Subroutine
name: called CC=12 SCAR=24.9
Pod
undocumented
| |||||||||||||
| 30 | # Detect the rhost class name | ||||||||||||
| 31 | # @param [Sisimai::Fact] argvs Decoded email object | ||||||||||||
| 32 | # @return [String] rhost class name | ||||||||||||
| 33 | 3425 | my $class = shift; | |||||||||||
| 34 | 3425 | ▶ | my $argvs = shift || return ""; | ||||||||||
|
Condition50%1/2
shift() || (return '')
MC/DC0%0/1
shift() || (return '')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 35 | |||||||||||||
| 36 | 3425 | my $rhostclass = ""; | |||||||||||
| 37 | 3425 | ▶ | my $clienthost = lc $argvs->{"lhost"} || ""; | ||||||||||
|
Condition100%2/2
lc $argvs->{'lhost'} || ''
MC/DC100%1/1
lc $argvs->{'lhost'} || ''
lc $argvs->{'lhost'}
Truth table100%2/2
A
A= lc $argvs->{'lhost'}
| |||||||||||||
| 38 | 3425 | ▶ | my $remotehost = lc $argvs->{"rhost"} || ""; | ||||||||||
|
Condition100%2/2
lc $argvs->{'rhost'} || ''
MC/DC100%1/1
lc $argvs->{'rhost'} || ''
lc $argvs->{'rhost'}
Truth table100%2/2
A
A= lc $argvs->{'rhost'}
| |||||||||||||
| 39 | 3425 | ▶ | my $domainpart = lc $argvs->{"destination"} || ""; | ||||||||||
|
Condition50%1/2
lc $argvs->{'destination'} || ''
MC/DC0%0/1
lc $argvs->{'destination'} || ''
lc $argvs->{'destination'}
Truth table50%1/2
A
A= lc $argvs->{'destination'}
| |||||||||||||
| 40 | |||||||||||||
| 41 | 3425 | ▶ | FINDRHOST: while( $rhostclass eq "" ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | # Try to match the hostname patterns with the following order: | ||||||||||||
| 43 | # 1. destination: The domain part of the recipient address | ||||||||||||
| 44 | # 2. rhost: remote hostname | ||||||||||||
| 45 | # 3. lhost: local MTA hostname | ||||||||||||
| 46 | 3425 | for my $e ( keys %$RhostClass ) { | |||||||||||
| 47 | # Try to match the domain part with each value of RhostClass | ||||||||||||
| 48 | 65772 | ▶ | next unless grep { index($_, $domainpart) > -1 } $RhostClass->{ $e }->@*; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 49 | 338 | $rhostclass = $e; last FINDRHOST; | |||||||||||
| 50 | } | ||||||||||||
| 51 | |||||||||||||
| 52 | 3087 | for my $e ( keys %$RhostClass ) { | |||||||||||
| 53 | # Try to match the remote host with each value of RhostClass | ||||||||||||
| 54 | 56440 | ▶ | next unless grep { index($remotehost, $_) > -1 } $RhostClass->{ $e }->@*; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 55 | 597 | $rhostclass = $e; last FINDRHOST; | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | # Neither the remote host nor the destination did not matched with any value of RhostClass | ||||||||||||
| 59 | 2490 | for my $e ( keys %$RhostClass ) { | |||||||||||
| 60 | # Try to match the client host with each value of RhostClass | ||||||||||||
| 61 | 46378 | ▶ | next unless grep { index($clienthost, $_) > -1 } $RhostClass->{ $e }->@*; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 62 | 249 | $rhostclass = $e; last FINDRHOST; | |||||||||||
| 63 | } | ||||||||||||
| 64 | 2241 | last; | |||||||||||
| 65 | } | ||||||||||||
| 66 | 3425 | return $rhostclass; | |||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | 3336 | ▶ | sub find { | ||||||||||
|
Subroutine
find: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||
| 70 | # Detect the bounce reason from certain remote hosts | ||||||||||||
| 71 | # @param [Sisimai::Fact] argvs Decoded email object | ||||||||||||
| 72 | # @return [String] The value of bounce reason | ||||||||||||
| 73 | 3336 | my $class = shift; | |||||||||||
| 74 | 3336 | ▶ | my $argvs = shift || return ""; | ||||||||||
|
Condition100%2/2
shift() || (return '')
MC/DC100%1/1
shift() || (return '')
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 75 | 3335 | ▶ | my $rhost = __PACKAGE__->name($argvs) || return ""; | ||||||||||
|
Condition100%2/2
__PACKAGE__->name($argvs) || (return '')
MC/DC100%1/1
__PACKAGE__->name($argvs) || (return '')
__PACKAGE__->name($argvs)
Truth table100%2/2
A
A= __PACKAGE__->name($argvs)
| |||||||||||||
| 76 | |||||||||||||
| 77 | 1094 | $rhost = __PACKAGE__."::".$rhost; (my $modulepath = $rhost) =~ s|::|/|g; | |||||||||||
| 78 | 1094 | require $modulepath.'.pm'; | |||||||||||
| 79 | 1094 | return $rhost->find($argvs); | |||||||||||
| 80 | } | ||||||||||||
| 81 | |||||||||||||
| 82 | 86 | 1; | |||||||||||
| 83 | __END__ | ||||||||||||