Software /
code /
prosody
Comparison
util/prosodyctl/check.lua @ 12385:92b35a41bb3c
prosodyctl: check turn: compare correct addresses for relay mismatch detection (thanks Zash)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 05 Mar 2022 20:47:40 +0000 |
parent | 12384:53b4549c2209 |
child | 12390:71b5c9b8b07a |
comparison
equal
deleted
inserted
replaced
12384:53b4549c2209 | 12385:92b35a41bb3c |
---|---|
60 end | 60 end |
61 return false, "Probe endpoint did not return a success status"; | 61 return false, "Probe endpoint did not return a success status"; |
62 end | 62 end |
63 | 63 |
64 local function check_turn_service(turn_service, ping_service) | 64 local function check_turn_service(turn_service, ping_service) |
65 local array = require "util.array"; | |
66 local ip = require "util.ip"; | |
67 local set = require "util.set"; | |
65 local stun = require "net.stun"; | 68 local stun = require "net.stun"; |
66 local ip = require "util.ip"; | |
67 | 69 |
68 -- Create UDP socket for communication with the server | 70 -- Create UDP socket for communication with the server |
69 local sock = assert(require "socket".udp()); | 71 local sock = assert(require "socket".udp()); |
70 sock:setsockname("*", 0); | 72 sock:setsockname("*", 0); |
71 sock:setpeername(turn_service.host, turn_service.port); | 73 sock:setpeername(turn_service.host, turn_service.port); |
247 if not result.external_ip_pong then | 249 if not result.external_ip_pong then |
248 result.error = "Ping server did not return an address"; | 250 result.error = "Ping server did not return an address"; |
249 return result; | 251 return result; |
250 end | 252 end |
251 | 253 |
252 if result.external_ip.address ~= result.external_ip_pong.address then | 254 local relayed_address_set = set.new(array.pluck(result.relayed_addresses, "address")); |
255 if not relayed_address_set:contains(result.external_ip_pong.address) then | |
253 table.insert(result.warnings, "TURN external IP vs relay address mismatch! Is the TURN server behind a NAT and misconfigured?"); | 256 table.insert(result.warnings, "TURN external IP vs relay address mismatch! Is the TURN server behind a NAT and misconfigured?"); |
254 end | 257 end |
255 | 258 |
256 -- | 259 -- |
257 | 260 |