HadronZoo Unique Server IDs
Both Epistula and the Dissemino web engine have to generate formal message ids. As both programs are based on the HadronZoo Library, it made sense for there to be a library fuction to perform this task. The name of CreateMessageID was easier to choose than the method. Neither program could assume the presence of the other and even if they were both running on the same server, they did not share program space. Yet as is obvious, if both were deployed to serve a domain, both would create message ids based on the same domain name. The part of the id that was a 'unique identifier generated independently by the source machine', had to be unique even though there were independent and asynchronous sources, on the source machine.
The CreateMessageID function generates ids with the following components:-
- Date and time of the form YYYYMMDD.hhmmss - A 'last second' counter or LSC (see below) - The client IP address - A nmemonc of 'ep' (Epistula) or 'ds' (Dissemino)
The overall form is:-
YYYYMMDD.hhmmss.LSC_clientIP_ep@domainName
Note that computer clocks are inherently inaccurate and can drift by several seconds in as little as an hour. Servers usually remedy this by syncing with an authorative time server but such arrangements are strictly a system administration matter. Programs must be able to cope with clock adjustments without any warning. A clock advancement will not cause the date and time component of an id to repeat but a clock retardation does have this propensity. The CreateMessageID function uses a static variable of 'latest known time' (LKT) and a dynamic variable of 'last-second' counter (LSC), to 'deny' clock retardations. The LKT has an intial value of midnight, Jan 1st, 0000. The process begins by reading the clock to an accuracy of one second. If the clock shows a LATER time than the LKT, the LKT is set equal to the clock and the LSC is set to 0 (this always happens in the first instance). If the clock shows a time EQUAL to or EARLIER than the LKT, the LKT is left unchanged but the LSC is incremented by 1. In ALL cases the id is formed of the LKT and the LSC, however where the clock was found to have an EARLIER time than the LKT the LKT and the LSC are separated by an underscore rather than a period.
Just think. If someone uses your server to write nasty mesages. You might have to recite that last paragraph in court!
A2 Message IDs and Forwarding Loops
It may be tempting to think message ids had a critical role in message forwarding. They don't. Message forwarding has two meanings according to RFC 5322 which states "One sense of forwarding is that a mail reading program can be told by a user to forward a copy of a message to another person, making the forwarded message the body of the new message". Bear in mind this is often automated. Crucially, RFC 5322 goes on to state "A forwarded message in this sense does not appear to have come from the original sender, but is an entirely new message from the forwarder of the message". An 'entirely new message' means an entirely new message id. Where mail clients (mail reading programs) do this, the message id cannot be used to detect forwarding loops.
Again quoting from RFC 5322, "Forwarding may also mean that a mail transport program gets a message and forwards it on to a different destination for final delivery". Here at least the mail server (mail transport program) is not altering the message id. Forwarding directives, from a declared local address to some target address, are usually suppressed by mail servers, where the message sender is the target. This prevents forwarding loops between two hosts but not where the loop involves more then two hosts. Given that message ids can be replaced at some point in the loop in some cases, means that message ids should not be used to detect forwarding loops in any cases. To overcome this, Epistula inserts a header of "X-Epistula-Fwrd" into forwarded messages. By convention, headers with names beginning with 'X' are considered 'application specific' and are passed on unaltered. This header will only exist if an Epistula server has at some point, forwarded the message - or some hacker is trying to attack the system. The X-Epistula-Fwrd value will be server IP address and the datum id. When the message comes around a second time, it is rejected.