On Fri, 24 Aug 2007, Guy Hulbert wrote: > > fqdn + time + peer TCP port will be pretty unique, regardless of > > fqdn is the trivial part > > rand will be "pretty unique" ...
Initial connection time, peer IP, and peer port will only repeat if the connection is torn down and restablished with the same peer reusing the same local port within the resolution of the timer. The check_earlytalker plugin ensures at least a one second pause in every SMTP session, so time() + peer IP + peer port will be far more unique than a random number :-) This combo would be unique among all hosts attached to the same routable networks -- two hosts on two different, unconnected networks could possibly get a connection from the same private IP + local port at the same time, but this "should be impossible" if the networks are connected. Adding this to plugins/logging/syslog works pretty well for forkserver: use Time::HiRes; ... if (!$self->{_logid}) { if ($self->connection->remote_ip) { $self->{_timestamp} = Time::HiRes::time(); $self->{_logid} = "t=" . $self->{_timestamp} . "/peer=" . $self->connection->remote_ip . ":" . $self->connection->remote_port; } } if ($self->connection->remote_ip) { $header = $self->{_logid} . " "; } syslog $priority, '%s%s', $header, join(' ', @log); syslog messages look like this: Aug 25 14:31:27 mailfoo qpsmtpd[4892]: t=1188077487.69488/peer=10.1.253.1:40911 check_earlytalker If there's an existing way to count the number of messages sent during the connection, then append the count to _logid and it becomes a message ID generator. If this isn't already somewhere in SMTP.pm, the queueing plugin could increment a counter.. or the logging plugin could watch for the string 'to email address :' & increment a (thread-safe) counter. That's a smidge brittle, tho.. a proper message counter would be less hacky. James