I have a file which lists net ranges which I treat very differently as
they come into the mail server. The format is pretty much just keys and
comments - I don't care for the returned value, just that the lookup
succeeds, and hopefully what the key value was. I have comments in the
file to remind me why I decided to add the range to the list also.
>From all that I have read in the docs, getting the hit key is not an option.
eg. file
128.103.0.0/16 # Harvard University
The lookup is along the lines of:
condition = ${lookup {$sender_host_address} \
iplsearch{LOOKUPFILES/listfile} \
{yes}{no} }
I know $value will give me everything after the matched key, which in
this case is "# Harvard University", but is it possible to return the
matched key instead?
The only possible method I have hit upon is to use the format of <lookup
key>: <lookup key>: eg.
128.103.0.0/16: 128.103.0.0/16
This gets me what I want, but I lose my comments on the same line. Or
perhaps using ${extract{<key>} ..} :
128.103.0.0/16: v=128.103.0.0/16 c="Harvard University"
Has anyone else ever wanted the key value from a lookup and have a
better solution? I have a few other lookups where this would be useful,
such as knowing if it was an exact or partial hit when doing a
partial-lsearch on HELO/EHLO values.