mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Fix #2302, save custom uploaded l7 pattern files on config.xml and replicate it to slave
This commit is contained in:
parent
732b160dba
commit
b5388f033c
@ -4084,6 +4084,17 @@ function read_layer7_config() {
|
||||
}
|
||||
}
|
||||
|
||||
function update_layer7_custom_patterns() {
|
||||
global $config;
|
||||
|
||||
if (!is_array($config['l7shaper']['custom_pat']))
|
||||
return;
|
||||
|
||||
foreach ($config['l7shaper']['custom_pat'] as $filename => $filecontent)
|
||||
if (!file_exists("/usr/local/share/protocols/" . $filename))
|
||||
@file_put_contents("/usr/local/share/protocols/" . $filename, base64_decode($filecontent));
|
||||
}
|
||||
|
||||
function generate_layer7_files() {
|
||||
global $layer7_rules_list, $g;
|
||||
|
||||
@ -4096,6 +4107,8 @@ function generate_layer7_files() {
|
||||
array_map('unlink', glob("{$g['tmp_path']}/*.l7"));
|
||||
}
|
||||
|
||||
update_layer7_custom_patterns();
|
||||
|
||||
foreach($layer7_rules_list as $l7rules) {
|
||||
if($l7rules->GetREnabled()) {
|
||||
$filename = $l7rules->GetRName() . ".l7";
|
||||
@ -4140,6 +4153,9 @@ function layer7_start_l7daemon() {
|
||||
|
||||
// This function uses /usr/local/share/protocols as a default directory for searching .pat files
|
||||
function generate_protocols_array() {
|
||||
|
||||
update_layer7_custom_patterns();
|
||||
|
||||
$protocols = return_dir_as_array("/usr/local/share/protocols");
|
||||
$protocols_new = array();
|
||||
if(is_array($protocols)) {
|
||||
|
||||
@ -42,6 +42,11 @@ require("guiconfig.inc");
|
||||
//Move the upload file to /usr/local/share/protocols (is_uploaded_file must use tmp_name as argument)
|
||||
if (($_POST['submit'] == gettext("Upload Pattern file")) && is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
|
||||
if(fileExtension($_FILES['ulfile']['name'])) {
|
||||
if (!is_array($config['l7shaper']['custom_pat']))
|
||||
$config['l7shaper']['custom_pat'] = array();
|
||||
|
||||
$config['l7shaper']['custom_pat'][$_FILES['ulfile']['name']] = base64_encode(file_get_contents($_FILES['ulfile']['tmp_name']));
|
||||
write_config(sprintf(gettext("Added custom l7 pattern %s"), $_FILES['ulfile']['name']));
|
||||
move_uploaded_file($_FILES['ulfile']['tmp_name'], "/usr/local/share/protocols/" . $_FILES['ulfile']['name']);
|
||||
$ulmsg = gettext("Uploaded file to") . " /usr/local/share/protocols/" . htmlentities($_FILES['ulfile']['name']);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user