# HG changeset patch # User Matthew Wild # Date 1646478925 0 # Node ID 5417ec7e2ee8684274fcc1a57d790199be133343 # Parent 1ba451c10f41bacde5cab29526ab73b847d477d1 prosodyctl: check turn: Allow specifying port for the ping service diff -r 1ba451c10f41 -r 5417ec7e2ee8 util/prosodyctl/check.lua --- a/util/prosodyctl/check.lua Sat Mar 05 11:10:18 2022 +0000 +++ b/util/prosodyctl/check.lua Sat Mar 05 11:15:25 2022 +0000 @@ -167,7 +167,14 @@ -- and receive a response. -- Resolve the IP of the ping service - local ping_service_ip, err = socket.dns.toip(ping_service); + local ping_host, ping_port = ping_service:match("^([^:]+):(%d+)$"); + if ping_host then + ping_port = tonumber(ping_port); + else + -- Only a hostname specified, use default STUN port + ping_host, ping_port = ping_service, 3478; + end + local ping_service_ip, err = socket.dns.toip(ping_host); if not ping_service_ip then result.error = "Unable to resolve external service: "..err; return result; @@ -198,7 +205,7 @@ local ping_data = stun.new_packet("binding"):serialize(); local ping_request = stun.new_packet("send", "indication"); - ping_request:add_xor_peer_address(ping_service_ip, 3478); + ping_request:add_xor_peer_address(ping_service_ip, ping_port); ping_request:add_attribute("data", ping_data); ping_request:add_attribute("username", turn_user); ping_request:add_attribute("realm", realm);