]> git.ipfire.org Git - thirdparty/haproxy.git/commit
EXAMPLES: fix IPV6 support for lua mailers script
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 9 May 2023 07:25:25 +0000 (09:25 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 9 May 2023 09:53:28 +0000 (11:53 +0200)
commitc75c41c35ff5924f994ea88dcc7b528a4c157c88
tree707bf4c3eeeb5b418d170cfc022de765817f8eba
parente59f7583ee9952a101f0430992add3fdff4db2ae
EXAMPLES: fix IPV6 support for lua mailers script

While this used to work fine with legacy mailers, IPV6 server support
for lua mailers script was overlooked so it is currently broken.

Indeed, within the lua script, server address was parsed as an IPV4
address to extract both ip and port and pass them to smtp_send_email()
function from Thierry FOURNIER.

From lua point of view: when fetching server address from
ProxyMailers.mailservers, server ip and port are not separated. Each
server address is represented using haproxy server address custom-format
(the one used to specify server addresses within haproxy config,
see 11. Address formats in haproxy configuration manual):

It is a string that contains both proto hint, ip and port.
(Such addresses are manipulated using str2sa_range() and sa2str()
in haproxy's code)

Parsing these custom-format addresses from lua to support multiple address
families is feasible since the format is properly documented in haproxy
configuration.

However, to keep things simple, and given that smtp_send_email() relies
on Socket.connect() function to set-up the tcp connection:

Socket.connect() already supports the full server address custom-format
when no explicit port argument is provided. Thus with minor code changes
we're able to pass the server string as it is.

With this, IPV6 smtp servers from mailers section are now automatically
supported when using lua mailers script.
examples/lua/mailers.lua