diff --git a/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml b/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml index 9f0b6487e..df9c1f5e9 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml +++ b/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml @@ -85,7 +85,7 @@ Please specify a valid portnumber, name, alias or range - interface gateways list + interface gateways list -g Specify a valid gateway from the list matching the networks ip protocol. diff --git a/src/opnsense/scripts/routes/gateways.php b/src/opnsense/scripts/routes/gateways.php index 672a88e0f..338d1490d 100755 --- a/src/opnsense/scripts/routes/gateways.php +++ b/src/opnsense/scripts/routes/gateways.php @@ -31,9 +31,10 @@ require_once 'config.inc'; require_once 'util.inc'; require_once 'interfaces.inc'; -$gateways = (new \OPNsense\Routing\Gateways())->gatewaysIndexedByName(true, true, true); +$mdl = (new \OPNsense\Routing\Gateways()); +$gateways = $mdl->gatewaysIndexedByName(true, true, true); -$ret = array(); +$ret = []; foreach ($gateways as $gateway) { if (is_ipaddr($gateway['gateway'] ?? '')) { @@ -43,4 +44,17 @@ foreach ($gateways as $gateway) { } } -echo json_encode($ret) . PHP_EOL; +$opts = getopt('gh', [], $optind); +$args = array_slice($argv, $optind); + +if (isset($opts['h'])) { + echo "Usage: gateways.php [-g] [-h]\n\n"; + echo "\t-g add gateway groups\n"; +} else { + if (isset($opts['g'])) { + foreach ($mdl->getGroupNames() as $name) { + $ret[$name] = $name; + } + } + echo json_encode($ret) . PHP_EOL; +} diff --git a/src/opnsense/service/conf/actions.d/actions_interface.conf b/src/opnsense/service/conf/actions.d/actions_interface.conf index 1f4c50d29..809929ce8 100644 --- a/src/opnsense/service/conf/actions.d/actions_interface.conf +++ b/src/opnsense/service/conf/actions.d/actions_interface.conf @@ -148,6 +148,7 @@ type: script_output [gateways.list] command:/usr/local/opnsense/scripts/routes/gateways.php +parameters: %s type:script_output message:list gateways cache_ttl:20