|
From: <jgr...@us...> - 2003-10-06 13:54:41
|
Update of /cvsroot/popfile/engine/Proxy
In directory sc8-pr-cvs1:/tmp/cvs-serv5598/Proxy
Modified Files:
NNTP.pm POP3.pm Proxy.pm SMTP.pm
Log Message:
ENABLE POPFILE PROXIES TO DIFFERENTIATE BETWEEN CONDITIONS:
Command sent to a remote server...
1. returned successfully
2. returned with an error message
3. timed out
Use this to enable the POP3 proxy to drop a connection on
a timeout rather than keeping retrying which can cause
confusion if the POP3 server suddenly starts responding to
a previous request.
Proxy/Proxy.pm:
Change get_response_ and echo_response_ so that the caller
can distinguish the three cases above.
Proxy/POP3.pm:
Use the new get_response_ and echo_response_ to drop the
connection if condition #3 occurs.
Proxy/SMTP.pm
Proxy/NNTP.pm:
Update to work with the new get_response_ and
echo_response_
tests/TestProxy.pm:
Update the tests that handle get_response_ and
echo_response_
Index: NNTP.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/NNTP.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** NNTP.pm 11 Sep 2003 20:55:10 -0000 1.20
--- NNTP.pm 6 Oct 2003 13:54:30 -0000 1.21
***************
*** 155,159 ****
if ( $command =~ /^ *QUIT/i ) {
if ( $news ) {
! $self->echo_response_( $news, $client, $command );
close $news;
} else {
--- 155,159 ----
if ( $command =~ /^ *QUIT/i ) {
if ( $news ) {
! last if ( $self->echo_response_( $news, $client, $command ) == 2 );
close $news;
} else {
***************
*** 211,215 ****
} elsif ( $connection_state eq "password needed" ) {
if ($command =~ /^ *AUTHINFO PASS (.*)/i) {
! my $response = $self->get_response_($news, $client, $command);
if ($response =~ /^281 .*/) {
--- 211,215 ----
} elsif ( $connection_state eq "password needed" ) {
if ($command =~ /^ *AUTHINFO PASS (.*)/i) {
! my ( $response, $ok ) = $self->get_response_($news, $client, $command);
if ($response =~ /^281 .*/) {
***************
*** 243,247 ****
if ( $command =~ /^ *ARTICLE (.*)/i ) {
! my $response = $self->get_response_( $news, $client, $command);
if ( $response =~ /^220 (.*) (.*)$/i) {
$count += 1;
--- 243,247 ----
if ( $command =~ /^ *ARTICLE (.*)/i ) {
! my ( $response, $ok ) = $self->get_response_( $news, $client, $command);
if ( $response =~ /^220 (.*) (.*)$/i) {
$count += 1;
***************
*** 263,267 ****
if ( $command =~ /^ *(LIST|HEAD|BODY|NEWGROUPS|NEWNEWS|LISTGROUP|XGTITLE|XINDEX|XHDR|XOVER|XPAT|XROVER|XTHREAD)/i ) {
! my $response = $self->get_response_( $news, $client, $command);
# 2xx (200) series response indicates multi-line text follows to .crlf
--- 263,267 ----
if ( $command =~ /^ *(LIST|HEAD|BODY|NEWGROUPS|NEWNEWS|LISTGROUP|XGTITLE|XINDEX|XHDR|XOVER|XPAT|XROVER|XTHREAD)/i ) {
! my ( $response, $ok ) = $self->get_response_( $news, $client, $command);
# 2xx (200) series response indicates multi-line text follows to .crlf
***************
*** 274,278 ****
if ( $ command =~ /^ *(HELP)/i ) {
! my $response = $self->get_response_( $news, $client, $command);
$self->echo_to_dot_( $news, $client, 0 ) if ( $response =~ /^1\d\d/ );
next;
--- 274,278 ----
if ( $ command =~ /^ *(HELP)/i ) {
! my ( $response, $ok ) = $self->get_response_( $news, $client, $command);
$self->echo_to_dot_( $news, $client, 0 ) if ( $response =~ /^1\d\d/ );
next;
***************
*** 289,293 ****
if ( $command =~ /^ *(IHAVE|POST|XRELPIC)/i ) {
! my $response = $self->get_response_( $news, $client, $command);
# 3xx (300) series response indicates multi-line text should be sent, up to .crlf
--- 289,293 ----
if ( $command =~ /^ *(IHAVE|POST|XRELPIC)/i ) {
! my ( $response, $ok ) = $self->get_response_( $news, $client, $command);
# 3xx (300) series response indicates multi-line text should be sent, up to .crlf
Index: POP3.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/POP3.pm,v
retrieving revision 1.77
retrieving revision 1.78
diff -C2 -d -r1.77 -r1.78
*** POP3.pm 11 Sep 2003 20:55:10 -0000 1.77
--- POP3.pm 6 Oct 2003 13:54:30 -0000 1.78
***************
*** 185,189 ****
# and send the reply straight to the client
! $self->echo_response_($mail, $client, 'USER ' . $4 );
} else {
--- 185,189 ----
# and send the reply straight to the client
! last if ( $self->echo_response_($mail, $client, 'USER ' . $4 ) == 2 );
} else {
***************
*** 206,210 ****
# and send the reply straight to the client
! $self->echo_response_($mail, $client, "APOP $4 $5" );
} else {
next;
--- 206,210 ----
# and send the reply straight to the client
! last if ( $self->echo_response_($mail, $client, "APOP $4 $5" ) == 2 );
} else {
next;
***************
*** 222,227 ****
# Loop until we get -ERR or +OK
! my $response;
! $response = $self->get_response_( $mail, $client, $command );
while ( ( ! ( $response =~ /\+OK/ ) ) && ( ! ( $response =~ /-ERR/ ) ) ) {
--- 222,226 ----
# Loop until we get -ERR or +OK
! my ( $response, $ok ) = $self->get_response_( $mail, $client, $command );
while ( ( ! ( $response =~ /\+OK/ ) ) && ( ! ( $response =~ /-ERR/ ) ) ) {
***************
*** 229,233 ****
$auth = <$client>;
$auth =~ s/(\015|\012)$//g;
! $response = $self->get_response_( $mail, $client, $auth );
}
} else {
--- 228,232 ----
$auth = <$client>;
$auth =~ s/(\015|\012)$//g;
! ( $response, $ok ) = $self->get_response_( $mail, $client, $auth );
}
} else {
***************
*** 244,248 ****
if ( $self->config_( 'secure_server' ) ne '' ) {
if ( $mail = $self->verify_connected_( $mail, $client, $self->config_( 'secure_server' ), $self->config_( 'secure_port' ) ) ) {
! if ( $self->echo_response_($mail, $client, "AUTH" ) ) {
$self->echo_to_dot_( $mail, $client );
}
--- 243,249 ----
if ( $self->config_( 'secure_server' ) ne '' ) {
if ( $mail = $self->verify_connected_( $mail, $client, $self->config_( 'secure_server' ), $self->config_( 'secure_port' ) ) ) {
! my $response = $self->echo_response_($mail, $client, "AUTH" );
! last if ( $response == 2 );
! if ( $response == 0 ) {
$self->echo_to_dot_( $mail, $client );
}
***************
*** 261,265 ****
if ( ( $command =~ /LIST ?(.*)?/i ) || # PROFILE BLOCK START
( $command =~ /UIDL ?(.*)?/i ) ) { # PROFILE BLOCK STOP
! if ( $self->echo_response_($mail, $client, $command ) ) {
$self->echo_to_dot_( $mail, $client ) if ( $1 eq '' );
}
--- 262,268 ----
if ( ( $command =~ /LIST ?(.*)?/i ) || # PROFILE BLOCK START
( $command =~ /UIDL ?(.*)?/i ) ) { # PROFILE BLOCK STOP
! my $response = $self->echo_response_($mail, $client, $command );
! last if ( $response == 2 );
! if ( $response == 0 ) {
$self->echo_to_dot_( $mail, $client ) if ( $1 eq '' );
}
***************
*** 311,315 ****
if ( $2 ne '99999999' ) {
if ( $self->config_( 'toptoo' ) ) {
! if ( $self->echo_response_($mail, $client, "RETR $count" ) ) {
# Classify without echoing to client, saving file for later RETR's
--- 314,320 ----
if ( $2 ne '99999999' ) {
if ( $self->config_( 'toptoo' ) ) {
! my $response = $self->echo_response_($mail, $client, "RETR $count" );
! last if ( $response == 2 );
! if ( $response == 0 ) {
# Classify without echoing to client, saving file for later RETR's
***************
*** 322,326 ****
# client. The +OK has already been sent by the RETR
! if ( $self->echo_response_($mail, $client, $command, 1 ) ) {
# Classify with pre-defined class, without saving, echoing to client
--- 327,333 ----
# client. The +OK has already been sent by the RETR
! $response = $self->echo_response_($mail, $client, $command, 1 );
! last if ( $response == 2 );
! if ( $response == 0 ) {
# Classify with pre-defined class, without saving, echoing to client
***************
*** 337,341 ****
}
} else {
! $self->echo_to_dot_( $mail, $client ) if ( $self->echo_response_($mail, $client, $command ) );
}
--- 344,352 ----
}
} else {
! my $response = $self->echo_response_($mail, $client, $command );
! last if ( $response == 2 );
! if ( $response == 0 ) {
! $self->echo_to_dot_( $mail, $client );
! }
}
***************
*** 352,356 ****
if ( $mail || $self->config_( 'secure_server' ) ne '' ) {
if ( $mail || ( $mail = $self->verify_connected_( $mail, $client, $self->config_( 'secure_server' ), $self->config_( 'secure_port' ) ) ) ) {
! $self->echo_to_dot_( $mail, $client ) if ( $self->echo_response_($mail, $client, "CAPA" ) );
} else {
next;
--- 363,371 ----
if ( $mail || $self->config_( 'secure_server' ) ne '' ) {
if ( $mail || ( $mail = $self->verify_connected_( $mail, $client, $self->config_( 'secure_server' ), $self->config_( 'secure_port' ) ) ) ) {
! my $response = $self->echo_response_($mail, $client, "CAPA" );
! last if ( $response == 2 );
! if ( $response == 0 ) {
! $self->echo_to_dot_( $mail, $client );
! }
} else {
next;
***************
*** 380,384 ****
( $command =~ /DELE (.*)/i ) ||
( $command =~ /RSET/i ) ) { # PROFILE BLOCK STOP
! $self->echo_response_($mail, $client, $command );
next;
}
--- 395,399 ----
( $command =~ /DELE (.*)/i ) ||
( $command =~ /RSET/i ) ) { # PROFILE BLOCK STOP
! last if ( $self->echo_response_($mail, $client, $command ) == 2 );
next;
}
***************
*** 442,446 ****
# we echo each line of the message until we hit the . at the end
! if ( $self->echo_response_($mail, $client, $command ) ) {
my $history_file;
( $class, $history_file ) = $self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 0, '' );
--- 457,463 ----
# we echo each line of the message until we hit the . at the end
! my $response = $self->echo_response_($mail, $client, $command );
! last if ( $response == 2 );
! if ( $response == 0 ) {
my $history_file;
( $class, $history_file ) = $self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 0, '' );
***************
*** 468,472 ****
if ( $command =~ /QUIT/i ) {
if ( $mail ) {
! $self->echo_response_( $mail, $client, $command );
close $mail;
} else {
--- 485,489 ----
if ( $command =~ /QUIT/i ) {
if ( $mail ) {
! last if ( $self->echo_response_( $mail, $client, $command ) == 2 );
close $mail;
} else {
***************
*** 479,483 ****
if ( $mail && $mail->connected ) {
! $self->echo_response_($mail, $client, $command );
next;
} else {
--- 496,500 ----
if ( $mail && $mail->connected ) {
! last if ( $self->echo_response_($mail, $client, $command ) == 2 );
next;
} else {
Index: Proxy.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/Proxy.pm,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** Proxy.pm 11 Sep 2003 17:27:11 -0000 1.36
--- Proxy.pm 6 Oct 2003 13:54:30 -0000 1.37
***************
*** 530,537 ****
#
# Send $command to $mail, receives the response and echoes it to the $client and the debug
! # output. Returns the response
#
# ---------------------------------------------------------------------------------------------
-
sub get_response_
{
--- 530,536 ----
#
# Send $command to $mail, receives the response and echoes it to the $client and the debug
! # output. Returns the response and a failure code indicating false if there was a timeout
#
# ---------------------------------------------------------------------------------------------
sub get_response_
{
***************
*** 544,548 ****
# $mail is undefined - return an error intead of crashing
$self->tee_( $client, "$self->{connection_timeout_error_}$eol" );
! return $self->{connection_timeout_error_};
}
--- 543,547 ----
# $mail is undefined - return an error intead of crashing
$self->tee_( $client, "$self->{connection_timeout_error_}$eol" );
! return ( $self->{connection_timeout_error_}, 0 );
}
***************
*** 565,569 ****
$self->tee_( $client, $response ) if ( !$suppress );
! return $response;
}
}
--- 564,568 ----
$self->tee_( $client, $response ) if ( !$suppress );
! return ( $response, 1 );
}
}
***************
*** 573,580 ****
$self->tee_( $client, "$self->{connection_timeout_error_}$eol" );
! return $self->{connection_timeout_error_};
} else {
$self->tee_($client, "");
! return "";
}
}
--- 572,579 ----
$self->tee_( $client, "$self->{connection_timeout_error_}$eol" );
! return ( $self->{connection_timeout_error_}, 0 );
} else {
$self->tee_($client, "");
! return ( "", 1 );
}
}
***************
*** 590,594 ****
#
# Send $command to $mail, receives the response and echoes it to the $client and the debug
! # output. Returns true if the response was +OK and false if not
#
# ---------------------------------------------------------------------------------------------
--- 589,599 ----
#
# Send $command to $mail, receives the response and echoes it to the $client and the debug
! # output.
! #
! # Returns one of three values
! #
! # 0 Successfully sent the command and got a positive response
! # 1 Sent the command and got a negative response
! # 2 Failed to send the command (e.g. a timeout occurred)
#
# ---------------------------------------------------------------------------------------------
***************
*** 599,603 ****
# Determine whether the response began with the string +OK. If it did then return 1
# else return 0
! return ( $self->get_response_( $mail, $client, $command, 0, $suppress ) =~ /$self->{good_response_}/ );
}
--- 604,619 ----
# Determine whether the response began with the string +OK. If it did then return 1
# else return 0
!
! my ( $response, $ok ) = $self->get_response_( $mail, $client, $command, 0, $suppress );
!
! if ( $ok == 1 ) {
! if ( $response =~ /$self->{good_response_}/ ) {
! return 0;
! } else {
! return 1;
! }
! } else {
! return 2;
! }
}
Index: SMTP.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/SMTP.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** SMTP.pm 11 Sep 2003 20:55:10 -0000 1.21
--- SMTP.pm 6 Oct 2003 13:54:30 -0000 1.22
***************
*** 287,291 ****
{
my ($self, $mail, $client, $command, $suppress) = @_;
! my $response = $self->get_response_( $mail, $client, $command );
if ( $response =~ /^\d\d\d-/ ) {
--- 287,291 ----
{
my ($self, $mail, $client, $command, $suppress) = @_;
! my ( $response, $ok ) = $self->get_response_( $mail, $client, $command );
if ( $response =~ /^\d\d\d-/ ) {
|