diff options
author | Matthew Wild <mwild1@gmail.com> | 2022-03-05 11:15:25 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2022-03-05 11:15:25 +0000 |
commit | 9df580f9975d2915de333efcbb573a61774c1257 (patch) | |
tree | 1f789b47cd49452646fd2b4e8027bf34bce88b51 /util | |
parent | 357c7e01420413882cba6173e6dfcb789455fcfe (diff) | |
download | prosody-9df580f9975d2915de333efcbb573a61774c1257.tar.gz prosody-9df580f9975d2915de333efcbb573a61774c1257.zip |
prosodyctl: check turn: Allow specifying port for the ping service
Diffstat (limited to 'util')
-rw-r--r-- | util/prosodyctl/check.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/util/prosodyctl/check.lua b/util/prosodyctl/check.lua index bc97ce44..f5236b86 100644 --- a/util/prosodyctl/check.lua +++ b/util/prosodyctl/check.lua @@ -167,7 +167,14 @@ local function check_turn_service(turn_service, ping_service) -- 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 function check_turn_service(turn_service, ping_service) 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); |