From kmoetken at gmail.com Sat Aug 13 18:44:17 2011 From: kmoetken at gmail.com (Kyle Oetken) Date: Sat, 13 Aug 2011 17:44:17 -0500 Subject: [Pymilter] uniqueID() Message-ID: In the example code this section assigns a unique ID to the milter instance: def __init__(self): # A new instance with each new connection. self.id = Milter.uniqueID() # Integer incremented with each call. In my testing it appears that the Milter.uniqueID appears to assign an ID to each specific tcp connection. As a result, if multiple messages are sent over that tcp connection each message will have the same uniqueID. Is there a good way to assign a unique ID to a particular message within the tcp connection? Thanks, Kyle Oetken -------------- next part -------------- An HTML attachment was scrubbed... URL: From stuart at bmsi.com Mon Aug 15 18:06:22 2011 From: stuart at bmsi.com (Stuart D Gathman) Date: Mon, 15 Aug 2011 18:06:22 -0400 Subject: [Pymilter] uniqueID() In-Reply-To: References: Message-ID: <4E49985E.5020700@bmsi.com> On 08/13/2011 06:44 PM, Kyle Oetken wrote: > In the example code this section assigns a unique ID to the milter instance: > > def__init__(self):# A new instance with each new connection. > self.id = Milter.uniqueID()# Integer incremented with each call. > In my testing it appears that the Milter.uniqueID appears to assign an > ID to each specific tcp connection. As a result, if multiple messages > are sent over that tcp connection each message will have the same > uniqueID. Is there a good way to assign a unique ID to a particular > message within the tcp connection? You could assign an id within envfrom also (or instead). However, since the tcp connection is a single thread, I would recommend simply incrementing a count in envfrom (no need for locking as with uniqueID). You can concatenate the connection id and message index to form an id unique for that milter run. Note that uniqueID starts over each time you start milter, it is not something you can use for Message-ID. You could count milter startups in a file, and prepend that to connection id and mail from count to form a unique id. -------------- next part -------------- An HTML attachment was scrubbed... URL: From oetkenky at hotmail.com Wed Aug 31 00:57:02 2011 From: oetkenky at hotmail.com (Kyle Oetken) Date: Wed, 31 Aug 2011 04:57:02 +0000 Subject: [Pymilter] uniqueID() In-Reply-To: <4E49985E.5020700@bmsi.com> References: , <4E49985E.5020700@bmsi.com> Message-ID: Stuart, Thanks for you help. Essentially I ended up adding the following to my code per you suggestion: 1) In the "hello" function: self.conn_counter = None 2) In the "envfrom" function: if self.conn_counter is None: self.conn_counter = 1 else: self.conn_counter += 1 I think added appended this value to the Milter.uniqueID when logging. It appears to do exactly what I needed. Thanks again, Kyle Date: Mon, 15 Aug 2011 18:06:22 -0400 From: stuart at bmsi.com To: pymilter at bmsi.com Subject: Re: [Pymilter] uniqueID() On 08/13/2011 06:44 PM, Kyle Oetken wrote: In the example code this section assigns a unique ID to the milter instance: def __init__(self): # A new instance with each new connection. self.id = Milter.uniqueID() # Integer incremented with each call. In my testing it appears that the Milter.uniqueID appears to assign an ID to each specific tcp connection. As a result, if multiple messages are sent over that tcp connection each message will have the same uniqueID. Is there a good way to assign a unique ID to a particular message within the tcp connection? You could assign an id within envfrom also (or instead). However, since the tcp connection is a single thread, I would recommend simply incrementing a count in envfrom (no need for locking as with uniqueID). You can concatenate the connection id and message index to form an id unique for that milter run. Note that uniqueID starts over each time you start milter, it is not something you can use for Message-ID. You could count milter startups in a file, and prepend that to connection id and mail from count to form a unique id. _______________________________________________ Pymilter mailing list Pymilter at bmsi.com http://www.bmsi.com/mailman/listinfo/pymilter -------------- next part -------------- An HTML attachment was scrubbed... URL: