Re: [exim] Greylist memcached perl implementation

Pàgina inicial
Delete this message
Reply to this message
Autor: Mike Cardwell
Data:  
A: exim-users
Assumpte: Re: [exim] Greylist memcached perl implementation
Todd Lyons wrote:

>>> This is an implementation of greylisting that uses memcached. Here
>>> are what I perceive as advantages:
>>> 4. Uses existing perl module.
>>> 5. Two macros do everything.
>>> 6. Uses config file to set memcache servers.
>> Talking to memcached directly from Exim by using ${readsocket} is
>> considerably more efficient than using Perl. Also, readsocket is
>> compiled into Exim by default and is therefore available in all of the
>> standard distributions of Exim.
>>
>> https://secure.grepular.com/blog/index.php/2009/05/13/accessing-memcached-from-exim/
>
> I definitely considered implementing it that way and originally
> preferred that over using perl. My understanding is that using
> readsocket works for when you have one memcached server. But my
> system has 3 memcached servers and using the perl modules distributes
> the keys across all 3 according to the key hash. Using the readsocket
> method I would have to come up with my own method of hashing the key
> to choose which server to connect to for the data. Since I'm
> primarily a perl guy, I suppose I stayed within my comfort zone
> because I don't know that I have the exim fu to properly and safely
> implement said hashing algorithm. Suggestions appreciated! As long
> as it can read an external file for the list of memcached servers,
> that meets my requirements.


Hmmm, you could do that all inside Exim to. Use ${readfile} to get the
list of memcached servers. Then, you'd use a simple hashing algorithm
like: Take the first octet of the IP address and then mod it against the
number of servers you've obtained. Eg:

${eval:${sg{$sender_host_address}{\N\..+\N}{}}%3}

That would return consistant values for each IP address where the values
are 0, 1 or 2. Then pick the server to connect to.

It's not straight forward though.

--
Mike Cardwell - IT Consultant and LAMP developer
Cardwell IT Ltd. (UK Reg'd Company #06920226) http://cardwellit.com/