mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-19 19:15:22 +00:00
Firewall: Automation: Filter - add gateway groups to the list, closes https://github.com/opnsense/core/issues/7625
This commit is contained in:
parent
0cae921340
commit
e648aefb76
@ -85,7 +85,7 @@
|
||||
<ValidationMessage>Please specify a valid portnumber, name, alias or range</ValidationMessage>
|
||||
</destination_port>
|
||||
<gateway type="JsonKeyValueStoreField">
|
||||
<ConfigdPopulateAct>interface gateways list</ConfigdPopulateAct>
|
||||
<ConfigdPopulateAct>interface gateways list -g</ConfigdPopulateAct>
|
||||
<ValidationMessage>Specify a valid gateway from the list matching the networks ip protocol.</ValidationMessage>
|
||||
</gateway>
|
||||
<log type="BooleanField">
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user