John Peacock wrote:
I'm going to work on some other changes and apply them to the 0.3x
branch (and then merge back to trunk), since it is odd that
Qpsmtpd::Connection->new() doesn't do anything with any initializing
parameters passed in (there is the start() sub to do that).
Actually, how do the following patches look. I abstracted out the
"hard" parameters of a Qpsmtpd::Connection object and added a clone()
method. I don't like that plugins/tls needs to know what parameters of
the connection object are "important" enough to copy.
John
=== lib/Qpsmtpd/Connection.pm
==================================================================
--- lib/Qpsmtpd/Connection.pm (revision 727)
+++ lib/Qpsmtpd/Connection.pm (local)
@@ -1,6 +1,19 @@
package Qpsmtpd::Connection;
use strict;
+# These are the only properties that are used for
+# new() or clone(); other properties are "soft" and
+# can be set/read directly, but won't be copied.
+my @parameters = qw(
+ remote_host
+ remote_ip
+ remote_info
+ remote_port
+ local_ip
+ local_port
+ relay_client
+);
+
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
@@ -14,14 +27,22 @@
my %args = @_;
- for my $f (qw(remote_host remote_ip remote_info remote_port
- local_ip local_port)) {
+ foreach my $f ( @parameters ) {
$self->$f($args{$f}) if $args{$f};
}
return $self;
}
+sub clone {
+ my $self = shift;
+ my $new = $self->new();
+ foreach my $f ( @parameters ) {
+ $new->$f($self->$f()) if $self->$f();
+ }
+ return $new;
+}
+
sub remote_host {
my $self = shift;
@_ and $self->{_remote_host} = shift;
=== plugins/tls
==================================================================
--- plugins/tls (revision 727)
+++ plugins/tls (local)
@@ -21,7 +21,7 @@
=cut
-use IO::Socket::SSL qw(debug1 debug2 debug3 debug4);
+use IO::Socket::SSL;# qw(debug1 debug2 debug3 debug4);
sub init {
my ($self, $qp, $cert, $key) = @_;
@@ -94,17 +94,8 @@
my $conn = $self->connection;
# Create a new connection object with subset of information collected
thus far
- $self->qp->connection(Qpsmtpd::Connection->new(
- map { $_ => $conn->$_ }
- qw(
- local_ip
- local_port
- remote_ip
- remote_port
- remote_host
- remote_info
- ),
- ));
+ my $newconn = $conn->clone();
+ $self->qp->connection($newconn);
$self->qp->reset_transaction;
*STDIN = *STDOUT = $self->connection->notes('tls_socket', $tlssocket);
$self->connection->notes('tls_enabled', 1);
@@ -116,7 +107,7 @@
return DENY, "TLS Negotiation Failed";
}
- warn("TLS setup returning\n");
+ $self->log(LOGWARN, "TLS setup returning\n");
return DONE;
}