aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2024-12-20 14:22:25 +0000
committerMatthew Wild <mwild1@gmail.com>2024-12-20 14:22:25 +0000
commita2b2d01c3e5c84da11a675b3848c5d28d7c919fa (patch)
tree494891a9e7777cb5b7dc1a2c8d1fb955776ca3b4
parenta2197df83202436ac7db20aed58060d018970942 (diff)
parentbca60e609d6a5433acaedafbe3b9cc3fd6661ff1 (diff)
downloadprosody-a2b2d01c3e5c84da11a675b3848c5d28d7c919fa.tar.gz
prosody-a2b2d01c3e5c84da11a675b3848c5d28d7c919fa.zip
Merge 0.12->trunk
-rw-r--r--util/prosodyctl/check.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/util/prosodyctl/check.lua b/util/prosodyctl/check.lua
index 8d085c85..ac8cc9c1 100644
--- a/util/prosodyctl/check.lua
+++ b/util/prosodyctl/check.lua
@@ -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");