Commit 5d33579e authored by Franco Fichtner's avatar Franco Fichtner

plugins: follow the footsteps of plugins_syslog() and plugins_services()

This looks simple enough now.  Discussed with @adschellevis.

(cherry picked from commit 1d73b3b5)
(cherry picked from commit ab4f67c8)
(cherry picked from commit 47c3fee7)
(cherry picked from commit 3947fff4)
parent 168bb7b5
...@@ -177,9 +177,15 @@ function write_config($desc = '', $backup = true) ...@@ -177,9 +177,15 @@ function write_config($desc = '', $backup = true)
return -1; return -1;
} }
if (function_exists('plugins_interfaces')) {
/* only pull plugins if plugins.inc was included before */
plugins_interfaces(false);
}
$cnf = OPNsense\Core\Config::getInstance(); $cnf = OPNsense\Core\Config::getInstance();
$cnf->fromArray($config); $cnf->fromArray($config);
$revision_info = make_config_revision_entry($desc); $revision_info = make_config_revision_entry($desc);
try { try {
$cnf->save($revision_info, $backup); $cnf->save($revision_info, $backup);
} catch (OPNsense\Core\ConfigException $e) { } catch (OPNsense\Core\ConfigException $e) {
......
...@@ -53,7 +53,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -53,7 +53,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
} }
unset($a_ifgroups[$id]); unset($a_ifgroups[$id]);
plugins_interfaces(false);
write_config(); write_config();
header("Location: interfaces_groups.php"); header("Location: interfaces_groups.php");
exit; exit;
......
...@@ -125,7 +125,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -125,7 +125,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// add new item // add new item
$a_ifgroups[] = $ifgroupentry; $a_ifgroups[] = $ifgroupentry;
} }
plugins_interfaces(false);
write_config(); write_config();
interface_group_setup($ifgroupentry); interface_group_setup($ifgroupentry);
header("Location: interfaces_groups.php"); header("Location: interfaces_groups.php");
......
...@@ -112,9 +112,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -112,9 +112,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
unset($config['ipsec']['phase1'][$p1entrydel]); unset($config['ipsec']['phase1'][$p1entrydel]);
} }
if (write_config()) { write_config();
mark_subsystem_dirty('ipsec'); mark_subsystem_dirty('ipsec');
}
header("Location: vpn_ipsec.php"); header("Location: vpn_ipsec.php");
exit; exit;
} elseif (!empty($_POST['act']) && $_POST['act'] == "delphase2" ) { } elseif (!empty($_POST['act']) && $_POST['act'] == "delphase2" ) {
...@@ -125,9 +124,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -125,9 +124,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
unset($config['ipsec']['phase2'][$p1entrydel]); unset($config['ipsec']['phase2'][$p1entrydel]);
} }
} }
if (write_config()) { write_config();
mark_subsystem_dirty('ipsec'); mark_subsystem_dirty('ipsec');
}
header("Location: vpn_ipsec.php"); header("Location: vpn_ipsec.php");
exit; exit;
} elseif (!empty($_POST['act']) && $_POST['act'] == "movep1" ) { } elseif (!empty($_POST['act']) && $_POST['act'] == "movep1" ) {
...@@ -141,9 +139,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -141,9 +139,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
$a_phase1 = legacy_move_config_list_items($a_phase1, $id, $_POST['p1entry']); $a_phase1 = legacy_move_config_list_items($a_phase1, $id, $_POST['p1entry']);
} }
if (write_config()) { write_config();
mark_subsystem_dirty('ipsec'); mark_subsystem_dirty('ipsec');
}
header("Location: vpn_ipsec.php"); header("Location: vpn_ipsec.php");
exit; exit;
} elseif (!empty($_POST['act']) && $_POST['act'] == "movep2" ) { } elseif (!empty($_POST['act']) && $_POST['act'] == "movep2" ) {
...@@ -157,9 +154,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -157,9 +154,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
$a_phase2 = legacy_move_config_list_items($a_phase2, $id, $_POST['p2entry']); $a_phase2 = legacy_move_config_list_items($a_phase2, $id, $_POST['p2entry']);
} }
if (write_config()) { write_config();
mark_subsystem_dirty('ipsec'); mark_subsystem_dirty('ipsec');
}
header("Location: vpn_ipsec.php"); header("Location: vpn_ipsec.php");
exit; exit;
} elseif (!empty($_POST['act']) && $_POST['act'] == "togglep1" && isset($a_phase1[$_POST['id']]) ) { } elseif (!empty($_POST['act']) && $_POST['act'] == "togglep1" && isset($a_phase1[$_POST['id']]) ) {
...@@ -169,9 +165,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -169,9 +165,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} else { } else {
$a_phase1[$_POST['id']]['disabled'] = true; $a_phase1[$_POST['id']]['disabled'] = true;
} }
if (write_config()) { write_config();
mark_subsystem_dirty('ipsec'); mark_subsystem_dirty('ipsec');
}
header("Location: vpn_ipsec.php"); header("Location: vpn_ipsec.php");
exit; exit;
} elseif (!empty($_POST['act']) && $_POST['act'] == "togglep2" && isset($a_phase2[$_POST['id']]) ) { } elseif (!empty($_POST['act']) && $_POST['act'] == "togglep2" && isset($a_phase2[$_POST['id']]) ) {
...@@ -181,9 +176,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -181,9 +176,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} else { } else {
$a_phase2[$_POST['id']]['disabled'] = true; $a_phase2[$_POST['id']]['disabled'] = true;
} }
if (write_config()) { write_config();
mark_subsystem_dirty('ipsec'); mark_subsystem_dirty('ipsec');
}
header("Location: vpn_ipsec.php"); header("Location: vpn_ipsec.php");
exit; exit;
} }
......
...@@ -31,6 +31,7 @@ require_once("guiconfig.inc"); ...@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("openvpn.inc"); require_once("openvpn.inc");
require_once("services.inc"); require_once("services.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("plugins.inc");
if (!isset($config['openvpn']['openvpn-client'])) { if (!isset($config['openvpn']['openvpn-client'])) {
$config['openvpn']['openvpn-client'] = array(); $config['openvpn']['openvpn-client'] = array();
......
...@@ -31,6 +31,7 @@ require_once("guiconfig.inc"); ...@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("openvpn.inc"); require_once("openvpn.inc");
require_once("services.inc"); require_once("services.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("plugins.inc");
// define all fields used in this form // define all fields used in this form
$all_form_fields = "custom_options,disable,common_name,block,description $all_form_fields = "custom_options,disable,common_name,block,description
......
...@@ -32,6 +32,7 @@ require_once("openvpn.inc"); ...@@ -32,6 +32,7 @@ require_once("openvpn.inc");
require_once("services.inc"); require_once("services.inc");
require_once("filter.inc"); require_once("filter.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("plugins.inc");
require_once("openvpn-client-export.inc"); require_once("openvpn-client-export.inc");
global $current_openvpn_version, $current_openvpn_version_rev; global $current_openvpn_version, $current_openvpn_version_rev;
......
...@@ -31,6 +31,7 @@ require_once("guiconfig.inc"); ...@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("openvpn.inc"); require_once("openvpn.inc");
require_once("services.inc"); require_once("services.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("plugins.inc");
if (!isset($config['openvpn']['openvpn-server'])) { if (!isset($config['openvpn']['openvpn-server'])) {
$config['openvpn']['openvpn-server'] = array(); $config['openvpn']['openvpn-server'] = array();
......
...@@ -33,6 +33,7 @@ require_once("filter.inc"); ...@@ -33,6 +33,7 @@ require_once("filter.inc");
require_once("rrd.inc"); require_once("rrd.inc");
require_once("system.inc"); require_once("system.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("plugins.inc");
/* /*
* find_ip_interface($ip): return the interface where an ip is defined * find_ip_interface($ip): return the interface where an ip is defined
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment