mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 00:54:41 +00:00
Merge pull request #1881 from evbevz/firewall-register-table
Firewall plugin: register table
This commit is contained in:
commit
65a6fb2cda
@ -405,6 +405,8 @@ function filter_configure_sync($verbose = false)
|
||||
}
|
||||
|
||||
$aliases = filter_generate_aliases($cnfint);
|
||||
$aliases .= "\n# Plugins tables\n";
|
||||
$aliases .= $fw->tablesToText();
|
||||
|
||||
if ($verbose) {
|
||||
echo '.';
|
||||
|
||||
@ -42,6 +42,7 @@ class Plugin
|
||||
private $interfaceMapping = array();
|
||||
private $gatewayMapping = array();
|
||||
private $systemDefaults = array();
|
||||
private $tables = array();
|
||||
|
||||
/**
|
||||
* init firewall plugin component
|
||||
@ -232,4 +233,35 @@ class Plugin
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* register a pf table
|
||||
* @param string $name table name
|
||||
* @param boolean $persist persistent
|
||||
* @param string $file get table from file
|
||||
*/
|
||||
public function registerTable($name, $persist = false, $file = null)
|
||||
{
|
||||
$this->tables[] = array('name' => $name, 'persist' => $persist, 'file' => $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch tables as text (pf tables part)
|
||||
* @return string
|
||||
*/
|
||||
public function tablesToText()
|
||||
{
|
||||
$result = "";
|
||||
foreach ($this->tables as $table) {
|
||||
$result .= "table <{$table['name']}>";
|
||||
if ($table['persist']) {
|
||||
$result .= " persist";
|
||||
}
|
||||
if (!empty($table['file'])) {
|
||||
$result .= " file \"{$table['file']}\"";
|
||||
}
|
||||
$result .= "\n";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user