/usr/share/perl5/Qpsmtpd/Connection.pm is in qpsmtpd 0.94-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | package Qpsmtpd::Connection;
use strict;
# All of these parameters depend only on the physical connection,
# i.e. not on anything sent from the remote machine. Hence, they
# are an appropriate set to use for either start() or clone(). Do
# not add parameters here unless they also meet that criteria.
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;
my $self = {};
bless($self, $class);
}
sub start {
my $self = shift;
$self = $self->new(@_) unless ref $self;
my %args = @_;
foreach my $f (@parameters) {
$self->$f($args{$f}) if $args{$f};
}
return $self;
}
sub clone {
my $self = shift;
my %args = @_;
my $new = $self->new();
foreach my $f (@parameters) {
$new->$f($self->$f()) if $self->$f();
}
$new->{_notes} = $self->{_notes} if defined $self->{_notes};
# reset the old connection object like it's done at the end of a connection
# to prevent leaks (like prefork/tls problem with the old SSL file handle
# still around)
$self->reset unless $args{no_reset};
# should we generate a new id here?
return $new;
}
sub remote_host {
my $self = shift;
@_ and $self->{_remote_host} = shift;
$self->{_remote_host};
}
sub remote_ip {
my $self = shift;
@_ and $self->{_remote_ip} = shift;
$self->{_remote_ip};
}
sub remote_port {
my $self = shift;
@_ and $self->{_remote_port} = shift;
$self->{_remote_port};
}
sub local_ip {
my $self = shift;
@_ and $self->{_local_ip} = shift;
$self->{_local_ip};
}
sub local_port {
my $self = shift;
@_ and $self->{_local_port} = shift;
$self->{_local_port};
}
sub remote_info {
my $self = shift;
@_ and $self->{_remote_info} = shift;
$self->{_remote_info};
}
sub relay_client {
my $self = shift;
@_ and $self->{_relay_client} = shift;
$self->{_relay_client};
}
sub hello {
my $self = shift;
@_ and $self->{_hello} = shift;
$self->{_hello};
}
sub hello_host {
my $self = shift;
@_ and $self->{_hello_host} = shift;
$self->{_hello_host};
}
sub notes {
my ($self, $key) = (shift, shift);
# Check for any additional arguments passed by the caller -- including undef
return $self->{_notes}->{$key} unless @_;
return $self->{_notes}->{$key} = shift;
}
sub reset {
my $self = shift;
$self->{_notes} = undef;
$self = $self->new;
}
1;
__END__
=head1 NAME
Qpsmtpd::Connection - A single SMTP connection
=head1 SYNOPSIS
my $rdns = $qp->connection->remote_host;
my $ip = $qp->connection->remote_ip;
=head1 DESCRIPTION
This class contains details about an individual SMTP connection. A
connection lasts the lifetime of a TCP connection to the SMTP server.
See also L<Qpsmtpd::Transaction> which is a class containing details
about an individual SMTP transaction. A transaction lasts from
C<MAIL FROM> to the end of the C<DATA> marker, or a C<RSET> command,
whichever comes first, whereas a connection lasts until the client
disconnects.
=head1 API
These API docs assume you already have a connection object. See the
source code if you need to construct one. You can access the connection
object via the C<Qpsmtpd> object's C<< $qp->connection >> method.
=head2 new ( )
Instantiates a new Qpsmtpd::Connection object.
=head2 start ( %args )
Initializes the connection object with %args attribute data.
=head2 remote_host( )
The remote host connecting to the server as looked up via reverse dns.
=head2 remote_ip( )
The remote IP address of the connecting host.
=head2 remote_port( )
The remote port.
=head2 remote_info( )
If your server does an ident lookup on the remote host, this is the
identity of the remote client.
=head2 local_ip( )
The local ip.
=head2 local_port( )
The local port.
=head2 hello( )
Either C<"helo"> or C<"ehlo"> depending on how the remote client
greeted your server.
NOTE: This field is empty during the helo or ehlo hooks, it is only
set after a successful return from those hooks.
=head2 hello_host( )
The host name specified in the C<HELO> or C<EHLO> command.
NOTE: This field is empty during the helo or ehlo hooks, it is only
set after a successful return from those hooks.
=head2 notes($key [, $value])
Get or set a note on the connection. This is a piece of data that you wish
to attach to the connection and read somewhere else. For example you can
use this to pass data between plugins.
=head2 clone([%args])
Returns a copy of the Qpsmtpd::Connection object. The optional args parameter
may contain:
=over 4
=item no_reset (1|0)
If true, do not reset the original connection object, the author has to care
about that: only the cloned connection object is reset at the end of the
connection
=back
=cut
=head2 relay_client( )
True if the client is allowed to relay messages.
=cut
|