Comparison

util/prosodyctl/check.lua @ 12382:574cf096a426

prosodyctl: check turn: fix traceback when server does not provide realm/nonce As coturn when installed out of the box on Debian (because auth isn't enabled?)
author Matthew Wild <mwild1@gmail.com>
date Sat, 05 Mar 2022 20:32:47 +0000
parent 12381:d999c2b3e289
child 12383:a9b6ed86b573
comparison
equal deleted inserted replaced
12381:d999c2b3e289 12382:574cf096a426
184 184
185 -- Ask the TURN server to allow packets from the ping service IP 185 -- Ask the TURN server to allow packets from the ping service IP
186 local perm_request = stun.new_packet("create-permission"); 186 local perm_request = stun.new_packet("create-permission");
187 perm_request:add_xor_peer_address(ping_service_ip); 187 perm_request:add_xor_peer_address(ping_service_ip);
188 perm_request:add_attribute("username", turn_user); 188 perm_request:add_attribute("username", turn_user);
189 perm_request:add_attribute("realm", realm); 189 if realm then
190 perm_request:add_attribute("nonce", nonce); 190 perm_request:add_attribute("realm", realm);
191 end
192 if nonce then
193 perm_request:add_attribute("nonce", nonce);
194 end
191 perm_request:add_message_integrity(key); 195 perm_request:add_message_integrity(key);
192 sock:send(perm_request:serialize()); 196 sock:send(perm_request:serialize());
193 197
194 local perm_response, err = receive_packet(); 198 local perm_response, err = receive_packet();
195 if not perm_response then 199 if not perm_response then
208 212
209 local ping_request = stun.new_packet("send", "indication"); 213 local ping_request = stun.new_packet("send", "indication");
210 ping_request:add_xor_peer_address(ping_service_ip, ping_port); 214 ping_request:add_xor_peer_address(ping_service_ip, ping_port);
211 ping_request:add_attribute("data", ping_data); 215 ping_request:add_attribute("data", ping_data);
212 ping_request:add_attribute("username", turn_user); 216 ping_request:add_attribute("username", turn_user);
213 ping_request:add_attribute("realm", realm); 217 if realm then
214 ping_request:add_attribute("nonce", nonce); 218 ping_request:add_attribute("realm", realm);
219 end
220 if nonce then
221 ping_request:add_attribute("nonce", nonce);
222 end
215 ping_request:add_message_integrity(key); 223 ping_request:add_message_integrity(key);
216 sock:send(ping_request:serialize()); 224 sock:send(ping_request:serialize());
217 225
218 local ping_response, err = receive_packet(); 226 local ping_response, err = receive_packet();
219 if not ping_response then 227 if not ping_response then