Software /
code /
prosody
Comparison
util/prosodyctl/check.lua @ 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 |
parent | 12372:1ba451c10f41 |
child | 12375:ea5e46601cfb |
comparison
equal
deleted
inserted
replaced
12372:1ba451c10f41 | 12373:5417ec7e2ee8 |
---|---|
165 | 165 |
166 -- Run the relay test - i.e. send a binding request to ping_service | 166 -- Run the relay test - i.e. send a binding request to ping_service |
167 -- and receive a response. | 167 -- and receive a response. |
168 | 168 |
169 -- Resolve the IP of the ping service | 169 -- Resolve the IP of the ping service |
170 local ping_service_ip, err = socket.dns.toip(ping_service); | 170 local ping_host, ping_port = ping_service:match("^([^:]+):(%d+)$"); |
171 if ping_host then | |
172 ping_port = tonumber(ping_port); | |
173 else | |
174 -- Only a hostname specified, use default STUN port | |
175 ping_host, ping_port = ping_service, 3478; | |
176 end | |
177 local ping_service_ip, err = socket.dns.toip(ping_host); | |
171 if not ping_service_ip then | 178 if not ping_service_ip then |
172 result.error = "Unable to resolve external service: "..err; | 179 result.error = "Unable to resolve external service: "..err; |
173 return result; | 180 return result; |
174 end | 181 end |
175 | 182 |
196 | 203 |
197 -- Ask the TURN server to relay a STUN binding request to the ping server | 204 -- Ask the TURN server to relay a STUN binding request to the ping server |
198 local ping_data = stun.new_packet("binding"):serialize(); | 205 local ping_data = stun.new_packet("binding"):serialize(); |
199 | 206 |
200 local ping_request = stun.new_packet("send", "indication"); | 207 local ping_request = stun.new_packet("send", "indication"); |
201 ping_request:add_xor_peer_address(ping_service_ip, 3478); | 208 ping_request:add_xor_peer_address(ping_service_ip, ping_port); |
202 ping_request:add_attribute("data", ping_data); | 209 ping_request:add_attribute("data", ping_data); |
203 ping_request:add_attribute("username", turn_user); | 210 ping_request:add_attribute("username", turn_user); |
204 ping_request:add_attribute("realm", realm); | 211 ping_request:add_attribute("realm", realm); |
205 ping_request:add_attribute("nonce", nonce); | 212 ping_request:add_attribute("nonce", nonce); |
206 ping_request:add_message_integrity(key); | 213 ping_request:add_message_integrity(key); |