Mailing List Archive

selecting random ip from file
Hello.

in smtp transport I'm doing something like:

interface = <; ${lookup{$sender_address_domain}
nwildlsearch{/etc/mail/custom_ip} }

which contains:

example.com: 1.1.1.1

That works fine but I would like to have few IPs assigned to a domain
and let exim choose these randomly like

example.com: 1.1.1.1, 2.2.2.2, 3.3.3.3

The number of ip addresses can be different for each domain listed there.

How to approach this in exim way?

(note file format can be easily changed like spaces instead of comas etc
if needed)

--
Arkadiusz Mi?kiewicz, arekm / ( maven.pl | pld-linux.org )

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: selecting random ip from file [ In reply to ]
On 12/05/2021 10:11, Arkadiusz Mi?kiewicz via Exim-users wrote:
> example.com: 1.1.1.1, 2.2.2.2, 3.3.3.3
>
> The number of ip addresses can be different for each domain listed there.
>
> How to approach this in exim way?

expansions:

listcount
randint
eval
listextract

--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: selecting random ip from file [ In reply to ]
W dniu 12.05.2021 o 11:42, Jeremy Harris via Exim-users pisze:
> On 12/05/2021 10:11, Arkadiusz Mi?kiewicz via Exim-users wrote:
>> example.com: 1.1.1.1, 2.2.2.2, 3.3.3.3
>>
>> The number of ip addresses can be different for each domain listed there.
>>
>> How to approach this in exim way?
>
> expansions:
>
> listcount
> randint
> eval
> listextract
>

Thanks for hints, were helpful

${listextract{${eval:${randint:${listcount:<, ${lookup{example.com}
nwildlsearch{/tmp/x}}}} + 1} }{<, ${lookup{example.com}
nwildlsearch{/tmp/x}}}}


--
Arkadiusz Mi?kiewicz, arekm / ( maven.pl | pld-linux.org )

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/