underground-software / singularity

KDLP: Beyond the event horizon
https://kdlp.underground.software
GNU General Public License v3.0
0 stars 0 forks source link

Improve Smtp Id Strings #106

Closed charliemirabile closed 4 months ago

charliemirabile commented 4 months ago

This PR overhauls how unique IDs are generated by the smtp program to make them more useful.

Instead of consisting of decimal values separated with periods, a fixed width hexadecimal format is adopted for easier parsing. The sub-values within the id are reordered so that the timestamp comes first followed by the pid followed by the sequence number so that sorting the values lexicographically produces a nice and sane ordering, and the timestamp is fetched once and cached at startup so that all ids generated by a given process will differ only in their sequence number.

The generic "sequence number" concept is split into a session number and then a unique id number within that session where sessions correspond to complete transactions from one user between logging in and executing RSET or QUIT. The log file containing the username and list of emails is always given the first id number within the session so that the unique id that refers to the overall session that a given email was part of can easily be determined from its unique id by simply replacing the sequence number with zero.