s/txn/transaction/ and perltidy cleanup (Steve Kemp)

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@885 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Ask Bjørn Hansen 2008-05-05 17:05:38 +00:00
parent f315e1c193
commit 569ea2a512
6 changed files with 41 additions and 41 deletions

View File

@ -87,7 +87,7 @@ sub register {
sub check_talker_poll { sub check_talker_poll {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
my $qp = $self->qp; my $qp = $self->qp;
my $conn = $qp->connection; my $conn = $qp->connection;
my $check_until = time + $self->{_args}{'wait'}; my $check_until = time + $self->{_args}{'wait'};
@ -97,7 +97,7 @@ sub check_talker_poll {
sub read_now { sub read_now {
my ($qp, $conn, $until, $phase) = @_; my ($qp, $conn, $until, $phase) = @_;
if ($qp->has_data) { if ($qp->has_data) {
$qp->log(LOGNOTICE, 'remote host started talking after $phase before we responded'); $qp->log(LOGNOTICE, 'remote host started talking after $phase before we responded');
$qp->clear_data if $phase eq 'data'; $qp->clear_data if $phase eq 'data';
@ -115,7 +115,7 @@ sub read_now {
sub check_talker_post { sub check_talker_post {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
my $conn = $self->qp->connection; my $conn = $self->qp->connection;
return DECLINED unless $conn->notes('earlytalker'); return DECLINED unless $conn->notes('earlytalker');
return DECLINED if $self->{'defer-reject'}; return DECLINED if $self->{'defer-reject'};
@ -125,7 +125,7 @@ sub check_talker_post {
} }
sub hook_mail { sub hook_mail {
my ($self, $txn) = @_; my ($self, $transaction) = @_;
return DECLINED unless $self->connection->notes('earlytalker'); return DECLINED unless $self->connection->notes('earlytalker');
return (DENY,$MSG) if $self->{_args}->{'action'} eq 'deny'; return (DENY,$MSG) if $self->{_args}->{'action'} eq 'deny';

View File

@ -102,7 +102,7 @@ sub register {
sub apr_connect_handler { sub apr_connect_handler {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
return DECLINED unless $self->{_args}{'check-at'}{CONNECT}; return DECLINED unless $self->{_args}{'check-at'}{CONNECT};
return DECLINED if ($self->qp->connection->notes('whitelistclient')); return DECLINED if ($self->qp->connection->notes('whitelistclient'));
my $ip = $self->qp->connection->remote_ip; my $ip = $self->qp->connection->remote_ip;
@ -110,7 +110,7 @@ sub apr_connect_handler {
my $c = $self->qp->{conn}; my $c = $self->qp->{conn};
my $socket = $c->client_socket; my $socket = $c->client_socket;
my $timeout = $self->{_args}->{'wait'} * 1_000_000; my $timeout = $self->{_args}->{'wait'} * 1_000_000;
my $rc = $socket->poll($c->pool, $timeout, APR::Const::POLLIN()); my $rc = $socket->poll($c->pool, $timeout, APR::Const::POLLIN());
if ($rc == APR::Const::SUCCESS()) { if ($rc == APR::Const::SUCCESS()) {
$self->log(LOGNOTICE, "remote host started talking before we said hello [$ip]"); $self->log(LOGNOTICE, "remote host started talking before we said hello [$ip]");
@ -130,7 +130,7 @@ sub apr_connect_handler {
sub apr_data_handler { sub apr_data_handler {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
return DECLINED unless $self->{_args}{'check-at'}{DATA}; return DECLINED unless $self->{_args}{'check-at'}{DATA};
return DECLINED if ($self->qp->connection->notes('whitelistclient')); return DECLINED if ($self->qp->connection->notes('whitelistclient'));
my $ip = $self->qp->connection->remote_ip; my $ip = $self->qp->connection->remote_ip;
@ -138,7 +138,7 @@ sub apr_data_handler {
my $c = $self->qp->{conn}; my $c = $self->qp->{conn};
my $socket = $c->client_socket; my $socket = $c->client_socket;
my $timeout = $self->{_args}->{'wait'} * 1_000_000; my $timeout = $self->{_args}->{'wait'} * 1_000_000;
my $rc = $socket->poll($c->pool, $timeout, APR::Const::POLLIN()); my $rc = $socket->poll($c->pool, $timeout, APR::Const::POLLIN());
if ($rc == APR::Const::SUCCESS()) { if ($rc == APR::Const::SUCCESS()) {
$self->log(LOGNOTICE, "remote host started talking before we said hello [$ip]"); $self->log(LOGNOTICE, "remote host started talking before we said hello [$ip]");
@ -199,7 +199,7 @@ sub data_handler {
} }
sub mail_handler { sub mail_handler {
my ($self, $txn) = @_; my ($self, $transaction) = @_;
my $msg = 'Connecting host started transmitting before SMTP greeting'; my $msg = 'Connecting host started transmitting before SMTP greeting';
return DECLINED unless $self->qp->connection->notes('earlytalker'); return DECLINED unless $self->qp->connection->notes('earlytalker');

View File

@ -183,9 +183,9 @@ sub register {
} }
sub log_output { sub log_output {
my ($self, $txn) = @_; my ($self, $transaction) = @_;
my $output = $self->{_log_format}; my $output = $self->{_log_format};
$output =~ s/%i/($txn->notes('logging-session-id') || 'parent')/ge; $output =~ s/%i/($transaction->notes('logging-session-id') || 'parent')/ge;
$output = strftime $output, localtime; $output = strftime $output, localtime;
$output; $output;
} }
@ -216,28 +216,28 @@ sub open_log {
# #
# Returns true if the file was reopened, zero if not, undef on error. # Returns true if the file was reopened, zero if not, undef on error.
sub maybe_reopen { sub maybe_reopen {
my ($self, $txn) = @_; my ($self, $transaction) = @_;
my $new_output = $self->log_output($txn); my $new_output = $self->log_output($transaction);
if (!$self->{_current_output} || if (!$self->{_current_output} ||
$self->{_current_output} ne $new_output || $self->{_current_output} ne $new_output ||
($self->{_reopen} && ($self->{_reopen} &&
!$txn->notes('file-reopened-this-session'))) { !$transaction->notes('file-reopened-this-session'))) {
unless ($self->open_log($new_output, $txn)) { unless ($self->open_log($new_output, $transaction)) {
return undef; return undef;
} }
$txn->notes('file-reopened-this-session', 1); $transaction->notes('file-reopened-this-session', 1);
return 1; return 1;
} }
return 0; return 0;
} }
sub hook_connect { sub hook_connect {
my ($self, $txn) = @_; my ($self, $transaction) = @_;
$txn->notes('file-logged-this-session', 0); $transaction->notes('file-logged-this-session', 0);
$txn->notes('file-reopened-this-session', 0); $transaction->notes('file-reopened-this-session', 0);
$txn->notes('logging-session-id', $transaction->notes('logging-session-id',
sprintf("%08d-%04d-%d", sprintf("%08d-%04d-%d",
scalar time, $$, ++$self->{_session_counter})); scalar time, $$, ++$self->{_session_counter}));
return DECLINED; return DECLINED;
@ -253,7 +253,7 @@ sub hook_disconnect {
} }
sub hook_logging { sub hook_logging {
my ($self, $txn, $trace, $hook, $plugin, @log) = @_; my ($self, $transaction, $trace, $hook, $plugin, @log) = @_;
return DECLINED if !defined $self->{_loglevel} or return DECLINED if !defined $self->{_loglevel} or
$trace > $self->{_loglevel}; $trace > $self->{_loglevel};
@ -265,11 +265,11 @@ sub hook_logging {
# - We haven't logged anything yet this session # - We haven't logged anything yet this session
if (!$self->{_f} || if (!$self->{_f} ||
!$self->{_nosplit} || !$self->{_nosplit} ||
!$txn->notes('file-logged-this-session')) { !$transaction->notes('file-logged-this-session')) {
unless (defined $self->maybe_reopen($txn)) { unless (defined $self->maybe_reopen($transaction)) {
return DECLINED; return DECLINED;
} }
$txn->notes('file-logged-this-session', 1); $transaction->notes('file-logged-this-session', 1);
} }
my $f = $self->{_f}; my $f = $self->{_f};

View File

@ -61,7 +61,7 @@ Normally, log messages will be mapped from the above log levels into the
syslog(3) log levels of their corresponding names. This will cause various syslog(3) log levels of their corresponding names. This will cause various
messages to appear or not in syslog outputs according to your syslogd messages to appear or not in syslog outputs according to your syslogd
configuration (typically /etc/syslog.conf). However, if the B<priority> configuration (typically /etc/syslog.conf). However, if the B<priority>
setting is used, all messages will be logged at that priority regardless of setting is used, all messages will be logged at that priority regardless of
what the original priority might have been. what the original priority might have been.
=item B<ident> =item B<ident>
@ -141,7 +141,7 @@ sub register {
$self->{_priority} = $1; $self->{_priority} = $1;
} }
} }
if ($args{ident} && $args{ident} =~ /^([\w\-.]+)$/) { if ($args{ident} && $args{ident} =~ /^([\w\-.]+)$/) {
$ident = $1; $ident = $1;
} }
@ -172,7 +172,7 @@ my %priorities_ = (
); );
sub hook_logging { sub hook_logging {
my ($self, $txn, $trace, $hook, $plugin, @log) = @_; my ($self, $transaction, $trace, $hook, $plugin, @log) = @_;
return DECLINED if $trace > $self->{_loglevel}; return DECLINED if $trace > $self->{_loglevel};
return DECLINED if defined $plugin and $plugin eq $self->plugin_name; return DECLINED if defined $plugin and $plugin eq $self->plugin_name;

View File

@ -78,7 +78,7 @@ sub register {
} }
sub hook_queue { sub hook_queue {
my ($self, $txn) = @_; my ($self, $transaction) = @_;
my $tmp_dir = $self->qp->config('spool_dir') || '/tmp'; my $tmp_dir = $self->qp->config('spool_dir') || '/tmp';
$tmp_dir = $1 if ($tmp_dir =~ /(.*)/); $tmp_dir = $1 if ($tmp_dir =~ /(.*)/);
@ -89,12 +89,12 @@ sub hook_queue {
} }
print $tmp "HELO ", hostname(), "\n", print $tmp "HELO ", hostname(), "\n",
"MAIL FROM:<", ($txn->sender->address || ''), ">\n"; "MAIL FROM:<", ($transaction->sender->address || ''), ">\n";
print $tmp "RCPT TO:<", ($_->address || ''), ">\n" print $tmp "RCPT TO:<", ($_->address || ''), ">\n"
for $txn->recipients; for $transaction->recipients;
print $tmp "DATA\n", $txn->header->as_string; print $tmp "DATA\n", $transaction->header->as_string;
$txn->body_resetpos; $transaction->body_resetpos;
while (my $line = $txn->body_getline) { while (my $line = $transaction->body_getline) {
$line =~ s/^\./../; $line =~ s/^\./../;
print $tmp $line; print $tmp $line;
} }
@ -107,7 +107,7 @@ sub hook_queue {
unless ($exim) { unless ($exim) {
$self->log(LOGERROR, "Could not execute $self->{_exim_path}: $!"); $self->log(LOGERROR, "Could not execute $self->{_exim_path}: $!");
unlink $tmpfn or $self->log(LOGERROR, "unlink: $tmpfn: $!"); unlink $tmpfn or $self->log(LOGERROR, "unlink: $tmpfn: $!");
return (DECLINED, "Internal error enqueuing mail"); return (DECLINED, "Internal error enqueuing mail");
} }
# Normally exim produces no output in BSMTP mode; anything that # Normally exim produces no output in BSMTP mode; anything that
# does come out is an error worth logging. # does come out is an error worth logging.

View File

@ -215,7 +215,7 @@ sub send_query {
if (defined $s1) { if (defined $s1) {
$self->{sockets}->{$z}->{$name}->{'txt'} = $s1; $self->{sockets}->{$z}->{$name}->{'txt'} = $s1;
$self->{socket_select}->add($s1); $self->{socket_select}->add($s1);
$self->{socket_idx}->{"$s1"} = $self->{socket_idx}->{"$s1"} =
$self->{socket_idx}->{"$s1"} = $index; $self->{socket_idx}->{"$s1"} = $index;
$count++; $count++;
} else { } else {
@ -251,18 +251,18 @@ sub evaluate {
} }
sub data_handler { sub data_handler {
my ($self, $txn) = @_; my ($self, $transaction) = @_;
my $l; my $l;
my $queries = 0; my $queries = 0;
my %pending; my %pending;
my @qp_continuations; my @qp_continuations;
$txn->body_resetpos; $transaction->body_resetpos;
while ($self->{check_headers} and $l = $txn->body_getline) { while ($self->{check_headers} and $l = $transaction->body_getline) {
chomp $l; chomp $l;
last if !$l; last if !$l;
} }
while ($l = $txn->body_getline) { while ($l = $transaction->body_getline) {
chomp $l; chomp $l;
if ($l =~ /(.*)=$/) { if ($l =~ /(.*)=$/) {
@ -378,7 +378,7 @@ sub data_handler {
} }
} }
} }
$txn->body_resetpos; $transaction->body_resetpos;
unless ($queries) { unless ($queries) {
$self->log(LOGINFO, "No URIs found in mail"); $self->log(LOGINFO, "No URIs found in mail");
@ -448,7 +448,7 @@ sub data_handler {
for (@matches) { for (@matches) {
$self->log(LOGWARN, $_->{desc}); $self->log(LOGWARN, $_->{desc});
if ($_->{action} eq 'add-header') { if ($_->{action} eq 'add-header') {
$txn->header->add('X-URIBL-Match', $_->{desc}); $transaction->header->add('X-URIBL-Match', $_->{desc});
} elsif ($_->{action} eq 'deny') { } elsif ($_->{action} eq 'deny') {
return (DENY, $_->{desc}); return (DENY, $_->{desc});
} elsif ($_->{action} eq 'denysoft') { } elsif ($_->{action} eq 'denysoft') {