mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 05:07:42 +03:00
Merge 0.12->trunk
This commit is contained in:
commit
a2b2d01c3e
1 changed files with 14 additions and 4 deletions
|
@ -70,10 +70,22 @@ local function check_turn_service(turn_service, ping_service)
|
|||
local ip = require "prosody.util.ip";
|
||||
local stun = require "prosody.net.stun";
|
||||
|
||||
local result = { warnings = {} };
|
||||
|
||||
-- Create UDP socket for communication with the server
|
||||
local sock = assert(require "socket".udp());
|
||||
sock:setsockname("*", 0);
|
||||
sock:setpeername(turn_service.host, turn_service.port);
|
||||
do
|
||||
local ok, err = sock:setsockname("*", 0);
|
||||
if not ok then
|
||||
result.error = "Unable to perform TURN test: setsockname: "..tostring(err);
|
||||
return result;
|
||||
end
|
||||
ok, err = sock:setpeername(turn_service.host, turn_service.port);
|
||||
if not ok then
|
||||
result.error = "Unable to perform TURN test: setpeername: "..tostring(err);
|
||||
return result;
|
||||
end
|
||||
end
|
||||
sock:settimeout(10);
|
||||
|
||||
-- Helper function to receive a packet
|
||||
|
@ -85,8 +97,6 @@ local function check_turn_service(turn_service, ping_service)
|
|||
return stun.new_packet():deserialize(raw_packet);
|
||||
end
|
||||
|
||||
local result = { warnings = {} };
|
||||
|
||||
-- Send a "binding" query, i.e. a request for our external IP/port
|
||||
local bind_query = stun.new_packet("binding", "request");
|
||||
bind_query:add_attribute("software", "prosodyctl check turn");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue