aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-02-22 13:41:05 +0100
committerKim Alvefur <zash@zash.se>2022-02-22 13:41:05 +0100
commitc460117e3c7a7d49f1bff3c785d9ec44e2750f8d (patch)
tree721f73de9b6cee6bb683ff53aad91365ab3cd914
parent36512eca292578726109ceeb3ee8e1293102fd29 (diff)
downloadprosody-c460117e3c7a7d49f1bff3c785d9ec44e2750f8d.tar.gz
prosody-c460117e3c7a7d49f1bff3c785d9ec44e2750f8d.zip
core.portmanager: Fix traceback on attempt to get non-existent service
If there's no such interface:port then `data` is nil and `data.service` errors.
-rw-r--r--core/portmanager.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/portmanager.lua b/core/portmanager.lua
index 95d42b77..38c74b66 100644
--- a/core/portmanager.lua
+++ b/core/portmanager.lua
@@ -216,7 +216,9 @@ function close(interface, port)
end
function get_service_at(interface, port)
- local data = active_services:search(nil, interface, port)[1][1];
+ local data = active_services:search(nil, interface, port);
+ if not data or not data[1] or not data[1][1] then return nil, "not-found"; end
+ data = data[1][1];
return data.service, data.server;
end