Added option in setup for unique main IP in agents - #1744
Former-commit-id: f8f9668a14818a01b811a73052e2e7e82e9a8c7a
This commit is contained in:
parent
561579580e
commit
6f65c9876f
|
@ -228,7 +228,9 @@ if($new_agent){
|
|||
}
|
||||
|
||||
$table->data[2][0] = __('IP Address');
|
||||
$table->data[2][1] = html_print_input_text ('direccion', $direccion_agente, '', 16, 100, true);
|
||||
$table->data[2][1] = html_print_input_text ('direccion', $direccion_agente, '', 16, 100, true).
|
||||
html_print_checkbox ("unique_ip", 1, $config['unique_ip'], true).__('Unique IP') .
|
||||
ui_print_help_tip (__("Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent"), true);
|
||||
|
||||
if ($id_agente) {
|
||||
$table->data[2][1] .= ' ';
|
||||
|
|
|
@ -81,6 +81,7 @@ $alias_as_name = 0;
|
|||
$direccion_agente = get_parameter('direccion', '');
|
||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||
$direccion_agente = io_safe_input($direccion_agente);
|
||||
$unique_ip = 0;
|
||||
$intervalo = SECONDS_5MINUTES;
|
||||
$ff_interval = 0;
|
||||
$quiet_module = 0;
|
||||
|
@ -160,6 +161,7 @@ if ($create_agent) {
|
|||
$alias = (string) get_parameter_post("alias",'');
|
||||
$alias_as_name = (int) get_parameter_post("alias_as_name", 0);
|
||||
$direccion_agente = (string) get_parameter_post("direccion",'');
|
||||
$unique_ip = (int) get_parameter_post("unique_ip", 0);
|
||||
|
||||
//safe_output only validate ip
|
||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||
|
@ -214,7 +216,12 @@ if ($create_agent) {
|
|||
$nombre_agente = $alias;
|
||||
}
|
||||
|
||||
if(!$exists_alias){
|
||||
if($unique_ip && $direccion_agente != ''){
|
||||
$sql = 'SELECT direccion FROM tagente WHERE direccion = "' . $direccion_agente . '"';
|
||||
$exists_ip = db_get_row_sql($sql);
|
||||
}
|
||||
|
||||
if(!$exists_alias && !$exists_ip){
|
||||
$id_agente = db_process_sql_insert (
|
||||
'tagente',
|
||||
array (
|
||||
|
@ -304,6 +311,9 @@ if ($create_agent) {
|
|||
if($exists_alias){
|
||||
$agent_creation_error = __('Could not be created, because name already exists');
|
||||
}
|
||||
elseif($exists_ip){
|
||||
$agent_creation_error = __('Could not be created, because IP already exists');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -712,6 +722,7 @@ if ($update_agent) { // if modified some agent paramenter
|
|||
$alias = str_replace('`','‘',(string) get_parameter_post ("alias", ""));
|
||||
$alias_as_name = (int) get_parameter_post ('alias_as_name', 0);
|
||||
$direccion_agente = (string) get_parameter_post ("direccion", '');
|
||||
$unique_ip = (int) get_parameter_post ('unique_ip', 0);
|
||||
//safe_output only validate ip
|
||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||
|
||||
|
@ -795,9 +806,18 @@ if ($update_agent) { // if modified some agent paramenter
|
|||
ui_print_error_message(__('No agent alias specified'));
|
||||
//If there is an agent with the same name, but a different ID
|
||||
}
|
||||
|
||||
if($unique_ip && $direccion_agente != ''){
|
||||
$sql = 'SELECT direccion FROM tagente WHERE direccion = "' . $direccion_agente . '"';
|
||||
$exists_ip = db_get_row_sql($sql);
|
||||
}
|
||||
|
||||
if ($grupo <= 0) {
|
||||
ui_print_error_message(__('The group id %d is incorrect.', $grupo));
|
||||
}
|
||||
elseif($exists_ip){
|
||||
ui_print_error_message(__('Duplicate main IP address'));
|
||||
}
|
||||
else {
|
||||
//If different IP is specified than previous, add the IP
|
||||
if ($direccion_agente != '' &&
|
||||
|
|
|
@ -230,6 +230,11 @@ $table->data[38][0] = __('Set alias as name by default in agent creation');
|
|||
$table->data[38][1] = __('Yes').' '.html_print_radio_button ('alias_as_name', 1, '', $config["alias_as_name"], true).' ';
|
||||
$table->data[38][1] .= __('No').' '.html_print_radio_button ('alias_as_name', 0, '', $config["alias_as_name"], true);
|
||||
|
||||
$table->data[39][0] = __('Unique IP') .
|
||||
ui_print_help_tip (__("Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent"), true);
|
||||
$table->data[39][1] = __('Yes').' '.html_print_radio_button ('unique_ip', 1, '', $config["unique_ip"], true).' ';
|
||||
$table->data[39][1] .= __('No').' '.html_print_radio_button ('unique_ip', 0, '', $config["unique_ip"], true);
|
||||
|
||||
echo '<form id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=general&pure='.$config['pure'].'">';
|
||||
|
||||
echo "<fieldset>";
|
||||
|
|
|
@ -208,6 +208,8 @@ function config_update_config () {
|
|||
$error_update[] = __('alias_as_name');
|
||||
if (!config_update_value ('auditdir', get_parameter('auditdir')))
|
||||
$error_update[] = __('Audit log directory');
|
||||
if (!config_update_value ('unique_ip', get_parameter('unique_ip')))
|
||||
$error_update[] = __('unique_ip');
|
||||
break;
|
||||
case 'enterprise':
|
||||
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
|
||||
|
@ -1123,6 +1125,10 @@ function config_process_config () {
|
|||
config_update_value ('limit_parameters_massive', ini_get("max_input_vars") / 2);
|
||||
}
|
||||
|
||||
if (!isset ($config["unique_ip"])) {
|
||||
config_update_value ('unique_ip', 0);
|
||||
}
|
||||
|
||||
/*
|
||||
*Parse the ACL IP list for access API
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue