# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1645533665 -3600
# Node ID 8119a58b3a5c8641f0129396ffce08d1c203055d
# Parent  bc30e1b9ad894dccf3d5f62232658e313cf89203
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.

diff -r bc30e1b9ad89 -r 8119a58b3a5c core/portmanager.lua
--- a/core/portmanager.lua	Tue Feb 22 14:17:27 2022 +0100
+++ b/core/portmanager.lua	Tue Feb 22 13:41:05 2022 +0100
@@ -216,7 +216,9 @@
 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