util/prosodyctl/check.lua
branch0.12
changeset 12470 9ee41552bca0
parent 12445 dc6263625069
child 12492 3183f358a88f
equal deleted inserted replaced
12464:f7e40f1a5f53 12470:9ee41552bca0
   151 
   151 
   152 	-- Check the response
   152 	-- Check the response
   153 	local alloc_response, err = receive_packet();
   153 	local alloc_response, err = receive_packet();
   154 	if not alloc_response then
   154 	if not alloc_response then
   155 		result.error = "TURN server did not response to allocation request: "..err;
   155 		result.error = "TURN server did not response to allocation request: "..err;
   156 		return;
   156 		return result;
   157 	elseif alloc_response:is_err_resp() then
   157 	elseif alloc_response:is_err_resp() then
   158 		result.error = ("TURN allocation failed: %d (%s)"):format(alloc_response:get_error());
   158 		result.error = ("TURN allocation failed: %d (%s)"):format(alloc_response:get_error());
   159 		return result;
   159 		return result;
   160 	elseif not alloc_response:is_success_resp() then
   160 	elseif not alloc_response:is_success_resp() then
   161 		result.error = ("Unexpected TURN response: %d (%s)"):format(alloc_response:get_type());
   161 		result.error = ("Unexpected TURN response: %d (%s)"):format(alloc_response:get_type());
   243 	end
   243 	end
   244 
   244 
   245 	local pong_data = ping_response:get_attribute("data");
   245 	local pong_data = ping_response:get_attribute("data");
   246 	if not pong_data then
   246 	if not pong_data then
   247 		result.error = "No data relayed from remote server";
   247 		result.error = "No data relayed from remote server";
   248 		return;
   248 		return result;
   249 	end
   249 	end
   250 	local pong = stun.new_packet():deserialize(pong_data);
   250 	local pong = stun.new_packet():deserialize(pong_data);
   251 
   251 
   252 	result.external_ip_pong = pong:get_xor_mapped_address();
   252 	result.external_ip_pong = pong:get_xor_mapped_address();
   253 	if not result.external_ip_pong then
   253 	if not result.external_ip_pong then