[Web] Hide up time of containers that are missing
[Web] Rename fail2ban logs to netfiter logs [Web] Adding timeout to curl requests for dockerapi, fixes #981 [Web] Removed cow from favicon
This commit is contained in:
@@ -7,6 +7,7 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
|
||||
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/json');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_POST, 0);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 4);
|
||||
$response = curl_exec($curl);
|
||||
if ($response === false) {
|
||||
$err = curl_error($curl);
|
||||
@@ -32,6 +33,7 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
|
||||
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/json');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_POST, 0);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 4);
|
||||
$response = curl_exec($curl);
|
||||
if ($response === false) {
|
||||
$err = curl_error($curl);
|
||||
@@ -58,6 +60,7 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
|
||||
if (ctype_xdigit($container_id) && ctype_alnum($attr1)) {
|
||||
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/' . $attr1);
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 4);
|
||||
if (!empty($attr2)) {
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($attr2));
|
||||
}
|
||||
|
@@ -4,30 +4,26 @@ function fail2ban($_action, $_data = null) {
|
||||
global $lang;
|
||||
switch ($_action) {
|
||||
case 'get':
|
||||
$data = array();
|
||||
$f2b_options = array();
|
||||
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$data['ban_time'] = $redis->Get('F2B_BAN_TIME');
|
||||
$data['max_attempts'] = $redis->Get('F2B_MAX_ATTEMPTS');
|
||||
$data['retry_window'] = $redis->Get('F2B_RETRY_WINDOW');
|
||||
$data['netban_ipv4'] = $redis->Get('F2B_NETBAN_IPV4');
|
||||
$data['netban_ipv6'] = $redis->Get('F2B_NETBAN_IPV6');
|
||||
$f2b_options = json_decode($redis->Get('F2B_OPTIONS'), true);
|
||||
$wl = $redis->hGetAll('F2B_WHITELIST');
|
||||
if (is_array($wl)) {
|
||||
foreach ($wl as $key => $value) {
|
||||
$tmp_data[] = $key;
|
||||
}
|
||||
if (isset($tmp_data)) {
|
||||
$data['whitelist'] = implode(PHP_EOL, $tmp_data);
|
||||
$f2b_options['whitelist'] = implode(PHP_EOL, $tmp_data);
|
||||
}
|
||||
else {
|
||||
$data['whitelist'] = "";
|
||||
$f2b_options['whitelist'] = "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data['whitelist'] = "";
|
||||
$f2b_options['whitelist'] = "";
|
||||
}
|
||||
}
|
||||
catch (RedisException $e) {
|
||||
@@ -37,7 +33,7 @@ function fail2ban($_action, $_data = null) {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return $data;
|
||||
return $f2b_options;
|
||||
break;
|
||||
case 'edit':
|
||||
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
||||
@@ -63,21 +59,16 @@ function fail2ban($_action, $_data = null) {
|
||||
return false;
|
||||
}
|
||||
$wl = $_data['whitelist'];
|
||||
$ban_time = ($ban_time < 60) ? 60 : $ban_time;
|
||||
|
||||
$netban_ipv4 = ($netban_ipv4 < 8) ? 8 : $netban_ipv4;
|
||||
$netban_ipv6 = ($netban_ipv6 < 8) ? 8 : $netban_ipv6;
|
||||
$netban_ipv4 = ($netban_ipv4 > 32) ? 32 : $netban_ipv4;
|
||||
$netban_ipv6 = ($netban_ipv6 > 128) ? 128 : $netban_ipv6;
|
||||
|
||||
$max_attempts = ($max_attempts < 1) ? 1 : $max_attempts;
|
||||
$retry_window = ($retry_window < 1) ? 1 : $retry_window;
|
||||
$f2b_options = array();
|
||||
$f2b_options['ban_time'] = ($ban_time < 60) ? 60 : $ban_time;
|
||||
$f2b_options['netban_ipv4'] = ($netban_ipv4 < 8) ? 8 : $netban_ipv4;
|
||||
$f2b_options['netban_ipv6'] = ($netban_ipv6 < 8) ? 8 : $netban_ipv6;
|
||||
$f2b_options['netban_ipv4'] = ($netban_ipv4 > 32) ? 32 : $netban_ipv4;
|
||||
$f2b_options['netban_ipv6'] = ($netban_ipv6 > 128) ? 128 : $netban_ipv6;
|
||||
$f2b_options['max_attempts'] = ($max_attempts < 1) ? 1 : $max_attempts;
|
||||
$f2b_options['retry_window'] = ($retry_window < 1) ? 1 : $retry_window;
|
||||
try {
|
||||
$redis->Set('F2B_BAN_TIME', $ban_time);
|
||||
$redis->Set('F2B_MAX_ATTEMPTS', $max_attempts);
|
||||
$redis->Set('F2B_RETRY_WINDOW', $retry_window);
|
||||
$redis->Set('F2B_NETBAN_IPV4', $netban_ipv4);
|
||||
$redis->Set('F2B_NETBAN_IPV6', $netban_ipv6);
|
||||
$redis->Set('F2B_OPTIONS', json_encode($f2b_options));
|
||||
$redis->Del('F2B_WHITELIST');
|
||||
if(!empty($wl)) {
|
||||
$wl_array = array_map('trim', preg_split( "/( |,|;|\n)/", $wl));
|
||||
|
@@ -1134,13 +1134,13 @@ function get_logs($container, $lines = false) {
|
||||
return $data_array;
|
||||
}
|
||||
}
|
||||
if ($container == "fail2ban-mailcow") {
|
||||
if ($container == "netfilter-mailcow") {
|
||||
if (!is_numeric($lines)) {
|
||||
list ($from, $to) = explode('-', $lines);
|
||||
$data = $redis->lRange('F2B_LOG', intval($from), intval($to));
|
||||
$data = $redis->lRange('NETFILTER_LOG', intval($from), intval($to));
|
||||
}
|
||||
else {
|
||||
$data = $redis->lRange('F2B_LOG', 0, intval($lines));
|
||||
$data = $redis->lRange('NETFILTER_LOG', 0, intval($lines));
|
||||
}
|
||||
if ($data) {
|
||||
foreach ($data as $json_line) {
|
||||
|
@@ -3,7 +3,7 @@ function init_db_schema() {
|
||||
try {
|
||||
global $pdo;
|
||||
|
||||
$db_version = "27012018_1721";
|
||||
$db_version = "30012018_1521";
|
||||
|
||||
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
@@ -21,10 +21,6 @@ function init_db_schema() {
|
||||
AND active = '1'
|
||||
AND address NOT LIKE '@%'
|
||||
GROUP BY goto;",
|
||||
"grouped_sender_acl" => "CREATE VIEW grouped_sender_acl (username, send_as_acl) AS
|
||||
SELECT logged_in_as, IFNULL(GROUP_CONCAT(send_as SEPARATOR ' '), '') AS send_as_acl FROM sender_acl
|
||||
WHERE send_as NOT LIKE '@%'
|
||||
GROUP BY logged_in_as;",
|
||||
"grouped_domain_alias_address" => "CREATE VIEW grouped_domain_alias_address (username, ad_alias) AS
|
||||
SELECT username, IFNULL(GROUP_CONCAT(local_part, '@', alias_domain SEPARATOR ' '), '') AS ad_alias FROM mailbox
|
||||
LEFT OUTER JOIN alias_domain ON target_domain=domain
|
||||
@@ -193,7 +189,6 @@ function init_db_schema() {
|
||||
"tls_enforce_out" => "TINYINT(1) NOT NULL DEFAULT '0'",
|
||||
"kind" => "VARCHAR(100) NOT NULL DEFAULT ''",
|
||||
"multiple_bookings" => "TINYINT(1) NOT NULL DEFAULT '0'",
|
||||
"wants_tagged_subject" => "TINYINT(1) NOT NULL DEFAULT '0'",
|
||||
"created" => "DATETIME(0) NOT NULL DEFAULT NOW(0)",
|
||||
"modified" => "DATETIME ON UPDATE CURRENT_TIMESTAMP",
|
||||
"active" => "TINYINT(1) NOT NULL DEFAULT '1'"
|
||||
@@ -250,7 +245,8 @@ function init_db_schema() {
|
||||
"eas_reset" => "TINYINT(1) NOT NULL DEFAULT '1'",
|
||||
"filters" => "TINYINT(1) NOT NULL DEFAULT '1'",
|
||||
"quarantaine" => "TINYINT(1) NOT NULL DEFAULT '1'",
|
||||
"bcc_maps" => "TINYINT(1) NOT NULL DEFAULT '1'",
|
||||
"bcc_maps" => "TINYINT(1) NOT NULL DEFAULT '0'",
|
||||
"recipient_maps" => "TINYINT(1) NOT NULL DEFAULT '0'",
|
||||
),
|
||||
"keys" => array(
|
||||
"fkey" => array(
|
||||
|
Reference in New Issue
Block a user