Software /
code /
prosody-modules
Changeset
6247:49fad071e644
mod_net_proxy: Use safer util.format for generating description string (thanks tom)
It appears that server_event may emit port numbers (src_port() in this case)
as strings, rather than integers. This causes string.format() to throw an
error.
Prosody's util.format is a more forgiving formatter and won't throw an error.
The server_event behaviour may be best fixed for the sake of consistency,
though.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 09 May 2025 10:00:15 +0100 |
parents | 6246:96dda21fba75 |
children | 6248:cc5c0f1dc89b |
files | mod_net_proxy/mod_net_proxy.lua |
diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_net_proxy/mod_net_proxy.lua Wed May 07 16:29:59 2025 +0200 +++ b/mod_net_proxy/mod_net_proxy.lua Fri May 09 10:00:15 2025 +0100 @@ -14,6 +14,7 @@ local net = require "util.net"; local set = require "util.set"; local portmanager = require "core.portmanager"; +local fmt = require "util.format".format; -- Backwards Compatibility local function net_ntop_bc(input) @@ -81,7 +82,7 @@ local proxy_data_mt = {}; proxy_data_mt.__index = proxy_data_mt; function proxy_data_mt:describe() - return string.format("proto=%s/%s src=%s:%d dst=%s:%d", + return fmt("proto=%s/%s src=%s:%d dst=%s:%d", self:addr_family_str(), self:transport_str(), self:src_addr(), self:src_port(), self:dst_addr(), self:dst_port()); end