|
From: <jgr...@us...> - 2003-11-10 20:15:54
|
Update of /cvsroot/popfile/engine/Proxy
In directory sc8-pr-cvs1:/tmp/cvs-serv4335/Proxy
Modified Files:
NNTP.pm POP3.pm Proxy.pm SMTP.pm
Log Message:
"Unixification of POPFile"
--------------------------
1. Change command line parsing to use Getopt so that in future
we can have real command line options. In the past an option
was equivalent to a configuration file item. So you could set
module_param value
inside popfile.cfg, but you could also to
popfile.pl -module_param value
on the command line. The new form of the latter is
popfile.pl --set module_param=value
For the ultimate in laziness you can also use the old style
if you precede the first old style parameter with --, e.g.
the old style command line above would work in the new scheme
if specified as follows
popfile.pl -- -module_param value
It is still even possible to use very old style parameters
from pre-OO days of POPFile with the addition of the --
popfile.pl -- -ui_port 8080
2. Make it possible for a module to disable itself and hence be
unloaded. Unloadable modules have an 'enabled' paramter (currently
supported by all proxies (POP3, NNTP and SMTP) and XML-RPC). If
this parameter is 0 then use if to return the value '2' from start()
which indicates to Loader that the module wishes to be removed.
POPFile/Configuration.pm:
Use Getopt to handle new style command line options. Make
parse_command_line return 0 if there's an error.
POPFile/Module.pm:
Update documentation on start().
POPFile/Loader.pm:
Check the return code from start() and if it is 2 unload the module.
Check the return code from parse_command_line so we halt if there's an
error in command-line parsing.
Proxy/Proxy.pm:
Initialize the 'enabled' parameter to 1.
Proxy/POP3.pm
Proxy/SMTP.pm
Proxy/NNTP.pm:
Use the 'enabled' parameter to return 2 from start() so that if we
are not enabled we get unloaded. Also if not enabled don't register
any UI components.
UI/XMLRPC.pm:
Use the 'enabled' parameter to return 2 from start() so that if we
are not enabled we get unloaded. Also if not enabled don't register
any UI components.
Classifier/Bayes.pm:
When classifying a message without saving to disk, still add the
XPL link.
tests.pl:
Code layout clean up.
tests/TestConfiguration.pm:
Update and improve tests for command-line parsing.
tests/TestProxy.pm:
Check for the initial setting of the 'enabled' parameter.
tests/TestPOP3.pm:
Check that the enabled parameter is interpreted by start() to mean
no start and return 2. Make the XTP tests less time sensitive.
Index: NNTP.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/NNTP.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** NNTP.pm 10 Nov 2003 10:37:56 -0000 1.22
--- NNTP.pm 10 Nov 2003 20:15:17 -0000 1.23
***************
*** 95,98 ****
--- 95,118 ----
$self->config_( 'welcome_string', "NNTP POPFile ($self->{version_}) server ready" );
+ return $self->SUPER::initialize();;
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # start
+ #
+ # Called to start the NNTP proxy module
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub start
+ {
+ my ( $self ) = @_;
+
+ # If we are not enabled then no further work happens in this module
+
+ if ( $self->config_( 'enabled' ) == 0 ) {
+ return 2;
+ }
+
# Tell the user interface module that we having a configuration
# item that needs a UI component
***************
*** 114,118 ****
$self );
! return 1;
}
--- 134,138 ----
$self );
! return $self->SUPER::start();;
}
Index: POP3.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/POP3.pm,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -d -r1.81 -r1.82
*** POP3.pm 10 Nov 2003 10:37:58 -0000 1.81
--- POP3.pm 10 Nov 2003 20:15:18 -0000 1.82
***************
*** 98,101 ****
--- 98,119 ----
$self->config_( 'welcome_string', "POP3 POPFile ($self->{version_}) server ready" );
+ return $self->SUPER::initialize();;
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # start
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub start
+ {
+ my ( $self ) = @_;
+
+ # If we are not enabled then no further work happens in this module
+
+ if ( $self->config_( 'enabled' ) == 0 ) {
+ return 2;
+ }
+
# Tell the user interface module that we having a configuration
# item that needs a UI component
***************
*** 124,139 ****
'pop3_secure_server_port',
$self ); # PROFILE BLOCK STOP
-
- return 1;
- }
-
- # ---------------------------------------------------------------------------------------------
- #
- # start
- #
- # ---------------------------------------------------------------------------------------------
- sub start
- {
- my ( $self ) = @_;
if ( $self->config_( 'welcome_string' ) =~ /^POP3 POPFile \(v\d+\.\d+\.\d+\) server ready$/ ) {
--- 142,145 ----
Index: Proxy.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/Proxy.pm,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** Proxy.pm 31 Oct 2003 16:17:15 -0000 1.38
--- Proxy.pm 10 Nov 2003 20:15:20 -0000 1.39
***************
*** 93,96 ****
--- 93,113 ----
# ---------------------------------------------------------------------------------------------
#
+ # initialize
+ #
+ # Called to initialize the Proxy, most of this is handled by a subclass of this
+ # but here we set the 'enabled' flag
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub initialize
+ {
+ my ( $self ) = @_;
+
+ $self->config_( 'enabled', 1 );
+
+ return 1;
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
# start
#
Index: SMTP.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/SMTP.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** SMTP.pm 10 Nov 2003 10:38:01 -0000 1.23
--- SMTP.pm 10 Nov 2003 20:15:21 -0000 1.24
***************
*** 27,32 ****
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
- # Modified by Sam Schinke (ssc...@us...)
- #
# ---------------------------------------------------------------------------------------------
--- 27,30 ----
***************
*** 73,79 ****
my ( $self ) = @_;
- # Disabled by default
- $self->config_( 'enabled', 0);
-
# By default we don't fork on Windows
$self->config_( 'force_fork', ($^O eq 'MSWin32')?0:1 );
--- 71,74 ----
***************
*** 92,95 ****
--- 87,110 ----
$self->config_( 'welcome_string', "SMTP POPFile ($self->{version_}) welcome" );
+ return $self->SUPER::initialize();;
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # start
+ #
+ # Called to start the SMTP proxy module
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub start
+ {
+ my ( $self ) = @_;
+
+ # If we are not enabled then no further work happens in this module
+
+ if ( $self->config_( 'enabled' ) == 0 ) {
+ return 2;
+ }
+
# Tell the user interface module that we having a configuration
# item that needs a UI component
***************
*** 115,119 ****
$self );
! return 1;
}
--- 130,134 ----
$self );
! return $self->SUPER::start();;
}
***************
*** 169,175 ****
next;
}
!
# Handle EHLO specially so we can control what ESMTP extensions are negotiated
!
if ( $command =~ /EHLO/i ) {
if ( $self->config_( 'chain_server' ) ) {
--- 184,190 ----
next;
}
!
# Handle EHLO specially so we can control what ESMTP extensions are negotiated
!
if ( $command =~ /EHLO/i ) {
if ( $self->config_( 'chain_server' ) ) {
***************
*** 182,187 ****
my $unsupported;
!
!
# RFC 1830, http://www.faqs.org/rfcs/rfc1830.html
# CHUNKING and BINARYMIME both require the support of the "BDAT" command
--- 197,202 ----
my $unsupported;
!
!
# RFC 1830, http://www.faqs.org/rfcs/rfc1830.html
# CHUNKING and BINARYMIME both require the support of the "BDAT" command
***************
*** 190,199 ****
$unsupported .= "CHUNKING|BINARYMIME";
!
# append unsupported ESMTP extensions to $unsupported here, important to maintain
# format of OPTION|OPTION2|OPTION3
!
$unsupported = qr/250\-$unsupported/;
!
$self->smtp_echo_response_( $mail, $client, $command, $unsupported );
--- 205,214 ----
$unsupported .= "CHUNKING|BINARYMIME";
!
# append unsupported ESMTP extensions to $unsupported here, important to maintain
# format of OPTION|OPTION2|OPTION3
!
$unsupported = qr/250\-$unsupported/;
!
$self->smtp_echo_response_( $mail, $client, $command, $unsupported );
***************
*** 442,443 ****
--- 457,460 ----
1;
+
+
|