-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathflowview_security.php
More file actions
42 lines (34 loc) · 1.04 KB
/
Copy pathflowview_security.php
File metadata and controls
42 lines (34 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
*/
function flowview_normalize_listener_port($value) {
if (is_int($value)) {
$port = $value;
} elseif (is_string($value) && preg_match('/^[0-9]+$/', $value)) {
$port = (int) $value;
} else {
return false;
}
if ($port < 1 || $port > 65535) {
return false;
}
return $port;
}
function flowview_build_listener_status_command($os, $port, $use_fallback = false) {
$port = flowview_normalize_listener_port($port);
if ($port === false) {
return false;
}
if ($os == 'freebsd') {
return "netstat -an | grep '." . $port . " '";
}
if ($use_fallback) {
return "netstat -an | grep ':" . $port . " '";
}
return "ss -lntu | grep ':" . $port . " '";
}