-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tiny code improvement in Sisimai::SMTP::Transcript->rise
- Loading branch information
1 parent
ffac89f
commit 0d467e7
Showing
1 changed file
with
34 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,46 +63,42 @@ sub rise { | |
my $p3 = index($e, '>>> '); | ||
if( $p3 == 0 ) { | ||
# SMTP client sent a command ">>> SMTP-command arguments" | ||
my $cv = Sisimai::SMTP::Command->find($e) || ''; | ||
if( length $cv ) { | ||
# >>> SMTP Command | ||
my $thecommand = $cv; | ||
my $commandarg = Sisimai::String->sweep(substr($e, index($e, $cv) + length($cv),)); | ||
|
||
push @$esmtp, $table->(); | ||
$cursession = $esmtp->[-1]; | ||
$cursession->{'command'} = uc $thecommand; | ||
|
||
if( $thecommand eq 'MAIL' || $thecommand eq 'RCPT' || $thecommand eq 'XFORWARD' ) { | ||
# MAIL or RCPT | ||
if( index($commandarg, 'FROM:') == 0 || index($commandarg, 'TO:') == 0 ) { | ||
# >>> MAIL FROM: <[email protected]> SIZE=65535 | ||
# >>> RCPT TO: <[email protected]> | ||
my $p4 = index($commandarg, '<'); | ||
my $p5 = index($commandarg, '>'); | ||
$cursession->{'argument'} = substr($commandarg, $p4 + 1, $p5 - $p4 - 1); | ||
$parameters = Sisimai::String->sweep(substr($commandarg, $p5 + 1,)); | ||
|
||
} else { | ||
# >>> XFORWARD NAME=neko2-nyaan3.y.example.co.jp ADDR=230.0.113.2 PORT=53672 | ||
# <<< 250 2.0.0 Ok | ||
# >>> XFORWARD PROTO=SMTP HELO=neko2-nyaan3.y.example.co.jp IDENT=2LYC6642BLzFK3MM SOURCE=REMOTE | ||
# <<< 250 2.0.0 Ok | ||
$parameters = $commandarg; | ||
$commandarg = ''; | ||
} | ||
|
||
for my $f ( split(" ", $parameters) ) { | ||
# SIZE=22022, PROTO=SMTP, and so on | ||
my $p6 = index($f, '='); next if $p6 < 1; | ||
my $p7 = length $f; next if $p7 < 3; | ||
my $ee = [split('=', $f)]; next unless scalar @$ee == 2; | ||
$cursession->{'parameter'}->{ lc $ee->[0] } = $ee->[1]; | ||
} | ||
my $thecommand = Sisimai::SMTP::Command->find($e) || next; | ||
my $commandarg = Sisimai::String->sweep(substr($e, index($e, $thecommand) + length($thecommand),)); | ||
|
||
push @$esmtp, $table->(); | ||
$cursession = $esmtp->[-1]; | ||
$cursession->{'command'} = uc $thecommand; | ||
|
||
if( $thecommand eq 'MAIL' || $thecommand eq 'RCPT' || $thecommand eq 'XFORWARD' ) { | ||
# MAIL or RCPT | ||
if( index($commandarg, 'FROM:') == 0 || index($commandarg, 'TO:') == 0 ) { | ||
# >>> MAIL FROM: <[email protected]> SIZE=65535 | ||
# >>> RCPT TO: <[email protected]> | ||
my $p4 = index($commandarg, '<'); | ||
my $p5 = index($commandarg, '>'); | ||
$cursession->{'argument'} = substr($commandarg, $p4 + 1, $p5 - $p4 - 1); | ||
$parameters = Sisimai::String->sweep(substr($commandarg, $p5 + 1,)); | ||
|
||
} else { | ||
# HELO, EHLO, AUTH, DATA, QUIT or Other SMTP command | ||
$cursession->{'argument'} = $commandarg; | ||
# >>> XFORWARD NAME=neko2-nyaan3.y.example.co.jp ADDR=230.0.113.2 PORT=53672 | ||
# <<< 250 2.0.0 Ok | ||
# >>> XFORWARD PROTO=SMTP HELO=neko2-nyaan3.y.example.co.jp IDENT=2LYC6642BLzFK3MM SOURCE=REMOTE | ||
# <<< 250 2.0.0 Ok | ||
$parameters = $commandarg; | ||
$commandarg = ''; | ||
} | ||
|
||
for my $f ( split(" ", $parameters) ) { | ||
# SIZE=22022, PROTO=SMTP, and so on | ||
my $p6 = index($f, '='); next if $p6 < 1; | ||
my $p7 = length $f; next if $p7 < 3; | ||
my $ee = [split('=', $f)]; next unless scalar @$ee == 2; | ||
$cursession->{'parameter'}->{ lc $ee->[0] } = $ee->[1]; | ||
} | ||
} else { | ||
# HELO, EHLO, AUTH, DATA, QUIT or Other SMTP command | ||
$cursession->{'argument'} = $commandarg; | ||
} | ||
} else { | ||
# SMTP server sent a response "<<< response text" | ||
|