comparison mod_portcheck/mod_portcheck.lua @ 4897:42a362a2bf51

mod_portcheck: Shell command to check if ports are open
author Kim Alvefur <zash@zash.se>
date Fri, 18 Feb 2022 18:35:45 +0100
parents
children adecfb36349e
comparison
equal deleted inserted replaced
4896:54fa2116bbf3 4897:42a362a2bf51
1 module:set_global();
2 local portmanager = require "core.portmanager";
3
4 local commands = module:shared("admin_shell/commands")
5
6 function commands.portcheck(session, line)
7 for desc, interface, port in line:gmatch("%s(%[?([%x:.]+)%]?:(%d+))") do
8 if interface == "*" then
9 interface = "0.0.0.0";
10 end
11 assert(portmanager.get_service_at(interface, tonumber(port)), desc);
12 end
13 session.print "OK";
14 end
15
16 function module.unload()
17 commands.portcheck = nil;
18 end