Software /
code /
prosody
Changeset
12373:5417ec7e2ee8
prosodyctl: check turn: Allow specifying port for the ping service
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 05 Mar 2022 11:15:25 +0000 |
parents | 12372:1ba451c10f41 |
children | 12374:0602245fc84e |
files | util/prosodyctl/check.lua |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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);