|
From: <jgr...@us...> - 2003-07-30 23:35:07
|
Update of /cvsroot/popfile/engine/Proxy
In directory sc8-pr-cvs1:/tmp/cvs-serv27315/Proxy
Modified Files:
POP3.pm
Log Message:
Clean up comments
Index: POP3.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/POP3.pm,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** POP3.pm 30 Jul 2003 23:06:12 -0000 1.65
--- POP3.pm 30 Jul 2003 23:35:03 -0000 1.66
***************
*** 77,99 ****
# item that needs a UI component
! $self->register_configuration_item_( 'configuration',
'pop3_port',
! $self );
! $self->register_configuration_item_( 'configuration',
'pop3_separator',
! $self );
! $self->register_configuration_item_( 'security',
'pop3_local',
! $self );
! $self->register_configuration_item_( 'chain',
'pop3_secure_server',
! $self );
! $self->register_configuration_item_( 'chain',
'pop3_secure_server_port',
! $self );
return 1;
--- 77,99 ----
# item that needs a UI component
! $self->register_configuration_item_( 'configuration', # PROFILE BLOCK START
'pop3_port',
! $self ); # PROFILE BLOCK STOP
! $self->register_configuration_item_( 'configuration', # PROFILE BLOCK START
'pop3_separator',
! $self ); # PROFILE BLOCK STOP
! $self->register_configuration_item_( 'security', # PROFILE BLOCK START
'pop3_local',
! $self ); # PROFILE BLOCK STOP
! $self->register_configuration_item_( 'chain', # PROFILE BLOCK START
'pop3_secure_server',
! $self ); # PROFILE BLOCK STOP
! $self->register_configuration_item_( 'chain', # PROFILE BLOCK START
'pop3_secure_server_port',
! $self ); # PROFILE BLOCK STOP
return 1;
***************
*** 115,131 ****
# Hash of indexes of downloaded messages
- my %downloaded;
! # Number of messages downloaded in this session
! #my $count = 0;
# The handle to the real mail server gets stored here
my $mail;
# Tell the client that we are ready for commands and identify our version number
$self->tee_( $client, "+OK " . $self->config_( 'welcome_string' ) . "$eol" );
# Retrieve commands from the client and process them until the client disconnects or
# we get a specific QUIT command
while ( <$client> ) {
my $command;
--- 115,132 ----
# Hash of indexes of downloaded messages
! my %downloaded;
# The handle to the real mail server gets stored here
+
my $mail;
# Tell the client that we are ready for commands and identify our version number
+
$self->tee_( $client, "+OK " . $self->config_( 'welcome_string' ) . "$eol" );
# Retrieve commands from the client and process them until the client disconnects or
# we get a specific QUIT command
+
while ( <$client> ) {
my $command;
***************
*** 134,137 ****
--- 135,139 ----
# Clean up the command so that it has a nice clean $eol at the end
+
$command =~ s/(\015|\012)//g;
***************
*** 144,147 ****
--- 146,150 ----
# will pull email from. Doing this means we can act as a proxy for multiple mail clients
# and mail accounts
+
my $user_command = 'USER (.+?)(:(\d+))?' . $self->config_( 'separator' ) . '(.+)';
if ( $command =~ /$user_command/i ) {
***************
*** 149,154 ****
--- 152,159 ----
print $pipe "LOGIN:$4$eol";
if ( $mail = $self->verify_connected_( $mail, $client, $1, $3 || 110 ) ) {
+
# Pass through the USER command with the actual user name for this server,
# and send the reply straight to the client
+
$self->echo_response_($mail, $client, 'USER ' . $4 );
} else {
***************
*** 169,176 ****
--- 174,184 ----
# User is issuing the APOP command to start a session with the remote server
+
if ( $command =~ /APOP (.*):((.*):)?(.*) (.*)/i ) {
if ( $mail = $self->verify_connected_( $mail, $client, $1, $3 || 110 ) ) {
+
# Pass through the USER command with the actual user name for this server,
# and send the reply straight to the client
+
$self->echo_response_($mail, $client, "APOP $4 $5" );
} else {
***************
*** 183,195 ****
--- 191,208 ----
# Secure authentication
+
if ( $command =~ /AUTH ([^ ]+)/ ) {
if ( $self->config_( 'secure_server' ) ne '' ) {
if ( $mail = $self->verify_connected_( $mail, $client, $self->config_( 'secure_server' ), $self->config_( 'secure_port' ) ) ) {
+
# Loop until we get -ERR or +OK
+
my $response;
$response = $self->get_response_( $mail, $client, $command );
while ( ( ! ( $response =~ /\+OK/ ) ) && ( ! ( $response =~ /-ERR/ ) ) ) {
+
# Check for an abort
+
if ( $self->{alive} == 0 ) {
last;
***************
*** 232,237 ****
# The client is requesting a LIST/UIDL of the messages
! if ( ( $command =~ /LIST ?(.*)?/i ) ||
! ( $command =~ /UIDL ?(.*)?/i ) ) {
if ( $self->echo_response_($mail, $client, $command ) ) {
$self->echo_to_dot_( $mail, $client ) if ( $1 eq '' );
--- 245,251 ----
# The client is requesting a LIST/UIDL of the messages
!
! 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 '' );
***************
*** 300,303 ****
--- 314,318 ----
# Tell the parent that we just handled a mail
+
print $pipe "CLASS:$class$eol";
print $pipe "NEWFL:$history_file$eol";
***************
*** 316,319 ****
--- 331,335 ----
# The CAPA command
+
if ( $command =~ /CAPA/i ) {
if ( $self->config_( 'secure_server' ) ne '' ) {
***************
*** 333,336 ****
--- 349,353 ----
# The HELO command results in a very simple response from us. We just echo that
# we are ready for commands
+
if ( $command =~ /HELO/i ) {
$self->tee_( $client, "+OK HELO POPFile Server Ready$eol" );
***************
*** 340,349 ****
# In the case of PASS, NOOP, XSENDER, STAT, DELE and RSET commands we simply pass it through to
# the real mail server for processing and echo the response back to the client
! if ( ( $command =~ /PASS (.*)/i ) ||
( $command =~ /NOOP/i ) ||
( $command =~ /STAT/i ) ||
( $command =~ /XSENDER (.*)/i ) ||
( $command =~ /DELE (.*)/i ) ||
! ( $command =~ /RSET/i ) ) {
$self->echo_response_($mail, $client, $command );
$self->flush_extra_( $mail, $client, 0 );
--- 357,367 ----
# In the case of PASS, NOOP, XSENDER, STAT, DELE and RSET commands we simply pass it through to
# the real mail server for processing and echo the response back to the client
!
! if ( ( $command =~ /PASS (.*)/i ) || # PROFILE BLOCK START
( $command =~ /NOOP/i ) ||
( $command =~ /STAT/i ) ||
( $command =~ /XSENDER (.*)/i ) ||
( $command =~ /DELE (.*)/i ) ||
! ( $command =~ /RSET/i ) ) { # PROFILE BLOCK STOP
$self->echo_response_($mail, $client, $command );
$self->flush_extra_( $mail, $client, 0 );
***************
*** 354,357 ****
--- 372,376 ----
# Note the horrible hack here where we detect a command of the form TOP x 99999999 this
# is done so that fetchmail can be used with POPFile.
+
if ( ( $command =~ /RETR (.*)/i ) || ( $command =~ /TOP (.*) 99999999/i ) ) {
my $count = $1;
***************
*** 382,389 ****
--- 401,410 ----
if ($bucket ne 'unknown class') {
+
# echo file, inserting known classification, without saving
$class = $self->{classifier__}->classify_and_modify( \*RETRFILE, $client, $download_count, 0, 1, $bucket );
} else {
+
# If the class wasn't saved properly, classify from disk normally
***************
*** 397,404 ****
--- 418,427 ----
next;
} else {
+
# Retrieve file directly from the server
# Get the message from the remote server, if there's an error then we're done, but if not then
# we echo each line of the message until we hit the . at the end
+
if ( $self->echo_response_($mail, $client, $command ) ) {
my $history_file;
***************
*** 406,413 ****
--- 429,438 ----
# Tell the parent that we just handled a mail
+
print $pipe "NEWFL:$history_file$eol";
print $pipe "CLASS:$class$eol";
# Note locally that file has been retrieved
+
$downloaded{$count} = 1;
***************
*** 421,424 ****
--- 446,450 ----
# real mail server, echo the response back up to the client and exit the while. We will
# close the connection immediately
+
if ( $command =~ /QUIT/i ) {
if ( $mail ) {
***************
*** 432,435 ****
--- 458,462 ----
# Don't know what this is so let's just pass it through and hope for the best
+
if ( $mail && $mail->connected ) {
$self->echo_response_($mail, $client, $command );
|