[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
master
andre.peters 2018-02-01 13:28:17 +01:00
parent c7280e182f
commit b2032c0e8a
12 changed files with 277 additions and 68 deletions

View File

@ -23,7 +23,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
<li role="presentation"><a href="#tab-postfix-logs" aria-controls="tab-postfix-logs" role="tab" data-toggle="tab">Postfix</a></li> <li role="presentation"><a href="#tab-postfix-logs" aria-controls="tab-postfix-logs" role="tab" data-toggle="tab">Postfix</a></li>
<li role="presentation"><a href="#tab-dovecot-logs" aria-controls="tab-dovecot-logs" role="tab" data-toggle="tab">Dovecot</a></li> <li role="presentation"><a href="#tab-dovecot-logs" aria-controls="tab-dovecot-logs" role="tab" data-toggle="tab">Dovecot</a></li>
<li role="presentation"><a href="#tab-sogo-logs" aria-controls="tab-sogo-logs" role="tab" data-toggle="tab">SOGo</a></li> <li role="presentation"><a href="#tab-sogo-logs" aria-controls="tab-sogo-logs" role="tab" data-toggle="tab">SOGo</a></li>
<li role="presentation"><a href="#tab-fail2ban-logs" aria-controls="tab-fail2ban-logs" role="tab" data-toggle="tab">Fail2ban</a></li> <li role="presentation"><a href="#tab-netfilter-logs" aria-controls="tab-netfilter-logs" role="tab" data-toggle="tab">Netfilter</a></li>
<li role="presentation"><a href="#tab-rspamd-history" aria-controls="tab-rspamd-history" role="tab" data-toggle="tab">Rspamd</a></li> <li role="presentation"><a href="#tab-rspamd-history" aria-controls="tab-rspamd-history" role="tab" data-toggle="tab">Rspamd</a></li>
<li role="presentation"><a href="#tab-autodiscover-logs" aria-controls="tab-autodiscover-logs" role="tab" data-toggle="tab">Autodiscover</a></li> <li role="presentation"><a href="#tab-autodiscover-logs" aria-controls="tab-autodiscover-logs" role="tab" data-toggle="tab">Autodiscover</a></li>
<li role="presentation"><a href="#tab-watchdog-logs" aria-controls="tab-watchdog-logs" role="tab" data-toggle="tab">Watchdog</a></li> <li role="presentation"><a href="#tab-watchdog-logs" aria-controls="tab-watchdog-logs" role="tab" data-toggle="tab">Watchdog</a></li>
@ -112,7 +112,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
'redis-mailcow', 'redis-mailcow',
'php-fpm-mailcow', 'php-fpm-mailcow',
'mysql-mailcow', 'mysql-mailcow',
'fail2ban-mailcow', 'netfilter-mailcow',
'clamd-mailcow' 'clamd-mailcow'
); );
foreach ($container_array as $container) { foreach ($container_array as $container) {
@ -123,21 +123,26 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
<?php <?php
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$StartedAt = date_parse($container_stats['State']['StartedAt']); $StartedAt = date_parse($container_stats['State']['StartedAt']);
$date = new \DateTime(); if ($StartedAt['hour'] !== false) {
$date->setTimestamp(mktime( $date = new \DateTime();
$StartedAt['hour'], $date->setTimestamp(mktime(
$StartedAt['minute'], $StartedAt['hour'],
$StartedAt['second'], $StartedAt['minute'],
$StartedAt['month'], $StartedAt['second'],
$StartedAt['day'], $StartedAt['month'],
$StartedAt['year'])); $StartedAt['day'],
$user_tz = new DateTimeZone(getenv('TZ')); $StartedAt['year']));
$date->setTimezone($user_tz); $user_tz = new DateTimeZone(getenv('TZ'));
$started = $date->format('r'); $date->setTimezone($user_tz);
$started = $date->format('r');
}
else {
$started = '?';
}
?> ?>
<small>(Started on <?=$started;?>), <small>(Started on <?=$started;?>),
<a href data-toggle="modal" data-container="<?=$container;?>" data-target="#RestartContainer">Restart</a></small> <a href data-toggle="modal" data-container="<?=$container;?>" data-target="#RestartContainer">Restart</a></small>
<span class="pull-right label label-<?=($container_stats['State']['Running'] == 1) ? 'success' : 'danger';?>">&nbsp;&nbsp;&nbsp;</span> <span class="pull-right label label-<?=($container_stats !== false && !empty($container_stats)) ? (($container_stats['State']['Running'] == 1) ? 'success' : 'danger') : 'default'; ?>">&nbsp;&nbsp;&nbsp;</span>
</li> </li>
<?php <?php
} }
@ -198,18 +203,18 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
</div> </div>
</div> </div>
<div role="tabpanel" class="tab-pane" id="tab-fail2ban-logs"> <div role="tabpanel" class="tab-pane" id="tab-netfilter-logs">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">Fail2ban <span class="badge badge-info log-lines"></span> <div class="panel-heading">Netfilter <span class="badge badge-info log-lines"></span>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button class="btn btn-xs btn-default add_log_lines" data-post-process="general_syslog" data-table="fail2ban_log" data-log-url="fail2ban" data-nrows="100">+ 100</button> <button class="btn btn-xs btn-default add_log_lines" data-post-process="general_syslog" data-table="netfilter_log" data-log-url="netfilter" data-nrows="100">+ 100</button>
<button class="btn btn-xs btn-default add_log_lines" data-post-process="general_syslog" data-table="fail2ban_log" data-log-url="fail2ban" data-nrows="1000">+ 1000</button> <button class="btn btn-xs btn-default add_log_lines" data-post-process="general_syslog" data-table="netfilter_log" data-log-url="netfilter" data-nrows="1000">+ 1000</button>
<button class="btn btn-xs btn-default" id="refresh_fail2ban_log"><?=$lang['admin']['refresh'];?></button> <button class="btn btn-xs btn-default" id="refresh_netfilter_log"><?=$lang['admin']['refresh'];?></button>
</div> </div>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-condensed" id="fail2ban_log"></table> <table class="table table-striped table-condensed" id="netfilter_log"></table>
</div> </div>
</div> </div>
</div> </div>

View File

@ -661,7 +661,7 @@ if (isset($_SESSION['mailcow_cc_role'])) {
?> ?>
<h4>Recipient map: <?=$result['recipient_map_old'];?></h4> <h4>Recipient map: <?=$result['recipient_map_old'];?></h4>
<br /> <br />
<form class="form-horizontal" data-id="editrecipient_map" role="form" method="post"> <form class="form-horizontal" data-id="edit_recipient_map" role="form" method="post">
<input type="hidden" value="0" name="active"> <input type="hidden" value="0" name="active">
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="recipient_map_new">New destination</label> <label class="control-label col-sm-2" for="recipient_map_new">New destination</label>
@ -679,7 +679,7 @@ if (isset($_SESSION['mailcow_cc_role'])) {
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-success" id="edit_selected" data-id="editrecipient_map" data-item="<?=$map;?>" data-api-url='edit/recipient_map' data-api-attr='{}' href="#"><?=$lang['edit']['save'];?></button> <button class="btn btn-success" id="edit_selected" data-id="edit_recipient_map" data-item="<?=$map;?>" data-api-url='edit/recipient_map' data-api-attr='{}' href="#"><?=$lang['edit']['save'];?></button>
</div> </div>
</div> </div>
</form> </form>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,198 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="267.80917"
height="306.93799"
viewBox="0 0 267.80917 306.93799"
enable-background="new 0 0 1600 1200"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="cow_protected_nb.svg"><metadata
id="metadata175"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs173" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1721"
inkscape:window-height="1177"
id="namedview171"
showgrid="false"
inkscape:zoom="1.5733333"
inkscape:cx="29.160751"
inkscape:cy="110.78493"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" /><g
id="g3"
transform="translate(-661.33429,-371.905)"><g
id="g11"><g
id="g13"><g
id="g15" /></g><g
id="g19"><g
id="g21" /></g><g
id="g25"><g
id="g27"><g
id="g29" /></g></g><g
id="g33"><g
id="g35"><g
id="g37" /></g></g></g><polyline
points="702.43,498.974 684.548,546.739 697.837,612.03 723.777,638.295 "
id="polyline43"
style="fill:#3d5263" /><g
id="g45"><g
id="g47"><polyline
points="669.541,457.293 684.791,493.55 705.121,503.375 735.319,465.213 "
id="polyline49"
style="fill:#fef3df" /><g
id="g51"><path
d="m 721.916,479.683 c 0,0 -22.477,-25.55 -49.782,-18.971 0,0 4.666,34.11 46.339,44.009 l 2.61,8.531 c 0,0 -65.598,-9.687 -59.326,-67.578 0,0 48.997,-19.88 72.582,15.103"
id="path53"
inkscape:connector-curvature="0"
style="fill:#b58765" /><polyline
points="920.935,457.293 905.688,493.55 885.359,503.375 855.16,465.213 "
id="polyline55"
style="fill:#fef3df" /><path
d="m 868.564,479.683 c 0,0 22.475,-25.55 49.779,-18.971 0,0 -4.663,34.11 -46.336,44.009 l -2.612,8.531 c 0,0 65.596,-9.687 59.326,-67.578 0,0 -48.995,-19.88 -72.584,15.103"
id="path57"
inkscape:connector-curvature="0"
style="fill:#b58765" /></g></g><path
d="m 737.898,653.506 55.932,0 20.22445,-212.1817 c -55.801,0 -116.21545,37.4237 -116.21545,85.2487 0,1.454 0.085,2.786 0.121,4.174 0.127,3.933 0.448,7.583 0.856,11.132 1.689,14.813 5.45,27.171 8.459,43.373 1.451,7.829 5.001,23.369 5.001,23.369 0.056,0.408 0.165,0.804 0.224,1.211 2.533,16.542 11.829,32.019 25.398,43.674 z"
id="path59"
inkscape:connector-curvature="0"
style="fill:#b58765"
sodipodi:nodetypes="cccscccccc" /><path
d="m 793.259,439.976 0,213.53 55.932,0 c 13.569,-11.654 22.862,-27.132 25.4,-43.675 0.058,-0.407 0.163,-0.803 0.221,-1.211 0,0 3.548,-15.539 5.001,-23.369 3.01,-16.202 6.773,-28.561 8.462,-43.371 0.404,-3.552 0.724,-7.202 0.846,-11.135 0.042,-1.388 0.126,-2.72 0.126,-4.174 -10e-4,-47.823 -40.183,-86.595 -95.988,-86.595 z"
id="path61"
inkscape:connector-curvature="0"
style="fill:#b58765" /><g
id="g63"><g
id="g65"><path
d="m 872.193,619.949 c 0,28.315 -35.083,51.278 -78.366,51.278 -43.289,0 -78.371,-22.963 -78.371,-51.278 0,-28.319 35.082,-51.278 78.371,-51.278 43.282,0 78.366,22.959 78.366,51.278 z"
id="path67"
inkscape:connector-curvature="0"
style="fill:#fef3df" /></g></g><g
id="g69"><g
id="g71"><g
id="g73"><path
d="m 758.318,612.03 c 0,6.213 -5.039,11.254 -11.258,11.254 -6.208,0 -11.25,-5.04 -11.25,-11.254 0,-6.222 5.042,-11.254 11.25,-11.254 6.218,0 11.258,5.033 11.258,11.254 z"
id="path75"
inkscape:connector-curvature="0"
style="fill:#5a3620" /></g></g><g
id="g77"><g
id="g79"><path
d="m 852.109,612.03 c 0,6.213 -5.036,11.254 -11.254,11.254 -6.216,0 -11.257,-5.04 -11.257,-11.254 0,-6.222 5.04,-11.254 11.257,-11.254 6.218,0 11.254,5.033 11.254,11.254 z"
id="path81"
inkscape:connector-curvature="0"
style="fill:#5a3620" /></g></g></g><g
id="g83"><path
d="m 886.474,532.301 c 0.354,-3.113 0.634,-6.31 0.743,-9.752 0.035,-1.217 0.109,-2.384 0.109,-3.66 0,-40.776 -33.361,-74.027 -80.219,-75.758 l -7.333,0.005 c -0.003,0 -0.003,0 -0.006,0 -0.007,0.018 -26.057,89.686 79.134,141.521 0.945,-4.316 2.078,-10.867 2.73,-14.369 2.638,-14.193 3.363,-25.015 4.842,-37.987 z"
id="path85"
inkscape:connector-curvature="0"
style="fill:#87654a" /></g><g
id="g87"><g
id="g89"><g
id="g91"><g
id="g93"><path
d="m 855.16,526.149 c 0,6.963 -5.649,12.608 -12.616,12.608 -6.961,0 -12.611,-5.645 -12.611,-12.608 0,-6.969 5.65,-12.611 12.611,-12.611 6.967,-10e-4 12.616,5.642 12.616,12.611 z"
id="path95"
inkscape:connector-curvature="0"
style="fill:#5a3620" /></g></g></g><g
id="g97"><g
id="g99"><g
id="g101"><path
d="m 763.301,526.149 c 0,6.963 -5.647,12.608 -12.609,12.608 -6.968,0 -12.609,-5.645 -12.609,-12.608 0,-6.969 5.641,-12.611 12.609,-12.611 6.962,-10e-4 12.609,5.642 12.609,12.611 z"
id="path103"
inkscape:connector-curvature="0"
style="fill:#5a3620" /></g></g></g><g
id="g105"><g
id="g107"><path
d="m 760.023,522.362 c 0,2.557 -2.07,4.628 -4.629,4.628 -2.557,0 -4.632,-2.071 -4.632,-4.628 0,-2.552 2.075,-4.625 4.632,-4.625 2.559,0.001 4.629,2.073 4.629,4.625 z"
id="path109"
inkscape:connector-curvature="0"
style="fill:#ffffff" /></g></g><g
id="g111"><g
id="g113"><path
d="m 851.024,522.362 c 0,2.557 -2.073,4.628 -4.628,4.628 -2.558,0 -4.63,-2.071 -4.63,-4.628 0,-2.552 2.072,-4.625 4.63,-4.625 2.555,0.001 4.628,2.073 4.628,4.625 z"
id="path115"
inkscape:connector-curvature="0"
style="fill:#ffffff" /></g></g></g></g><path
d="m 725.288,441.121 c 0,0 -18.232,-25.193 0,-41.628 0,0 13.123,32.005 40.233,31.495"
id="path117"
inkscape:connector-curvature="0"
style="fill:#fef3df" /><path
d="m 848.318,439.837 c 0,0 18.232,-25.193 0,-41.628 0,0 -13.123,32.005 -40.233,31.495"
id="path119"
inkscape:connector-curvature="0"
style="fill:#fef3df" /><path
d="m 797.53,438.453 c -66.381,0 -120.196,53.815 -120.196,120.196 0,66.381 53.815,120.194 120.196,120.194 66.382,0 120.196,-53.813 120.196,-120.194 C 917.725,492.268 863.912,438.453 797.53,438.453 Z m -11.958,215.653 c -52.997,0 -95.961,-43.845 -95.961,-97.931 0,-54.086 42.963,-97.931 95.961,-97.931 52.995,0 95.958,43.845 95.958,97.931 0,54.086 -42.963,97.931 -95.958,97.931 z"
id="path121"
inkscape:connector-curvature="0"
style="fill:#f1f2f2" /><g
id="g123"><path
d="m 793.003,443.237 c 66.381,0 120.194,53.815 120.194,120.196 0,30.711 -11.523,58.726 -30.475,79.973 21.631,-21.736 35.002,-51.697 35.002,-84.785 0,-66.38 -53.813,-120.196 -120.196,-120.196 -35.67,0 -67.706,15.545 -89.719,40.224 21.769,-21.872 51.899,-35.412 85.194,-35.412 z"
id="path125"
inkscape:connector-curvature="0"
style="fill:#ffffff" /></g><g
id="g127"><path
d="m 694.265,502.313 c 0,0 40.198,-14.957 95.353,-14.022 55.155,0.935 100.027,29.447 100.027,29.447 l 8.413,-57.492 c 0,0 -51.883,-35.524 -77.591,-59.829 -25.708,-24.306 -28.98,-28.512 -28.98,-28.512 0,0 -40.198,41.6 -66.373,56.557 -26.175,14.957 -35.524,20.566 -35.524,20.566 l 4.675,53.285 z"
id="path129"
inkscape:connector-curvature="0"
style="fill:#f1f2f2" /><path
d="m 752.039,427.289 c -5.218,15.301 0.741,45.305 6.446,52.941 4.565,-14.198 1.381,-39.668 -6.446,-52.941 z"
id="path131"
inkscape:connector-curvature="0"
style="fill:#97a3a2" /><path
d="m 792.297,477.645 c 8.422,-10.272 5.501,-61.687 -0.342,-73.723 -6.194,15.191 -10.634,65.438 0.342,73.723 z"
id="path133"
inkscape:connector-curvature="0"
style="fill:#97a3a2" /><path
d="m 720.593,443.412 c -3.983,12.281 1.136,36.168 5.784,42.198 3.474,-11.393 0.625,-31.693 -5.784,-42.198 z"
id="path135"
inkscape:connector-curvature="0"
style="fill:#97a3a2" /><path
d="m 832.42,429.158 c 5.218,15.301 -0.741,45.305 -6.446,52.941 -4.565,-14.197 -1.38,-39.667 6.446,-52.941 z"
id="path137"
inkscape:connector-curvature="0"
style="fill:#97a3a2" /><path
d="m 863.633,447.619 c 3.983,12.281 -1.136,36.168 -5.784,42.198 -3.474,-11.393 -0.625,-31.693 5.784,-42.198 z"
id="path139"
inkscape:connector-curvature="0"
style="fill:#97a3a2" /></g><g
id="g143" /><path
d="m 730.865,636.637 c 0,0 43.49,2.05 64.328,-35.861 0,0 14.758,30.223 46.61,34.759"
id="path157"
inkscape:connector-curvature="0"
style="opacity:0.1;fill:#3d5263" /><path
d="m 795.193,671.227 0,-60.691 c -13.615,27.608 -64.328,26.101 -64.328,26.101 0,0 3.306,8.89 3.788,9.853 0.482,0.963 21.508,12.52 21.508,12.52"
id="path159"
inkscape:connector-curvature="0"
style="fill:#f1f2f2" /><path
d="m 859.521,636.637 c 0,0 -50.713,1.507 -64.328,-26.101 l 0,60.691"
id="path161"
inkscape:connector-curvature="0"
style="fill:#f1f2f2" /><g
id="g163" /></g></svg>

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -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_URL, 'http://dockerapi:8080/containers/json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 0); curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 4);
$response = curl_exec($curl); $response = curl_exec($curl);
if ($response === false) { if ($response === false) {
$err = curl_error($curl); $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_URL, 'http://dockerapi:8080/containers/' . $container_id . '/json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 0); curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 4);
$response = curl_exec($curl); $response = curl_exec($curl);
if ($response === false) { if ($response === false) {
$err = curl_error($curl); $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)) { if (ctype_xdigit($container_id) && ctype_alnum($attr1)) {
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/' . $attr1); curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/' . $attr1);
curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 4);
if (!empty($attr2)) { if (!empty($attr2)) {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($attr2)); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($attr2));
} }

View File

@ -4,30 +4,26 @@ function fail2ban($_action, $_data = null) {
global $lang; global $lang;
switch ($_action) { switch ($_action) {
case 'get': case 'get':
$data = array(); $f2b_options = array();
if ($_SESSION['mailcow_cc_role'] != "admin") { if ($_SESSION['mailcow_cc_role'] != "admin") {
return false; return false;
} }
try { try {
$data['ban_time'] = $redis->Get('F2B_BAN_TIME'); $f2b_options = json_decode($redis->Get('F2B_OPTIONS'), true);
$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');
$wl = $redis->hGetAll('F2B_WHITELIST'); $wl = $redis->hGetAll('F2B_WHITELIST');
if (is_array($wl)) { if (is_array($wl)) {
foreach ($wl as $key => $value) { foreach ($wl as $key => $value) {
$tmp_data[] = $key; $tmp_data[] = $key;
} }
if (isset($tmp_data)) { if (isset($tmp_data)) {
$data['whitelist'] = implode(PHP_EOL, $tmp_data); $f2b_options['whitelist'] = implode(PHP_EOL, $tmp_data);
} }
else { else {
$data['whitelist'] = ""; $f2b_options['whitelist'] = "";
} }
} }
else { else {
$data['whitelist'] = ""; $f2b_options['whitelist'] = "";
} }
} }
catch (RedisException $e) { catch (RedisException $e) {
@ -37,7 +33,7 @@ function fail2ban($_action, $_data = null) {
); );
return false; return false;
} }
return $data; return $f2b_options;
break; break;
case 'edit': case 'edit':
if ($_SESSION['mailcow_cc_role'] != "admin") { if ($_SESSION['mailcow_cc_role'] != "admin") {
@ -63,21 +59,16 @@ function fail2ban($_action, $_data = null) {
return false; return false;
} }
$wl = $_data['whitelist']; $wl = $_data['whitelist'];
$ban_time = ($ban_time < 60) ? 60 : $ban_time; $f2b_options = array();
$f2b_options['ban_time'] = ($ban_time < 60) ? 60 : $ban_time;
$netban_ipv4 = ($netban_ipv4 < 8) ? 8 : $netban_ipv4; $f2b_options['netban_ipv4'] = ($netban_ipv4 < 8) ? 8 : $netban_ipv4;
$netban_ipv6 = ($netban_ipv6 < 8) ? 8 : $netban_ipv6; $f2b_options['netban_ipv6'] = ($netban_ipv6 < 8) ? 8 : $netban_ipv6;
$netban_ipv4 = ($netban_ipv4 > 32) ? 32 : $netban_ipv4; $f2b_options['netban_ipv4'] = ($netban_ipv4 > 32) ? 32 : $netban_ipv4;
$netban_ipv6 = ($netban_ipv6 > 128) ? 128 : $netban_ipv6; $f2b_options['netban_ipv6'] = ($netban_ipv6 > 128) ? 128 : $netban_ipv6;
$f2b_options['max_attempts'] = ($max_attempts < 1) ? 1 : $max_attempts;
$max_attempts = ($max_attempts < 1) ? 1 : $max_attempts; $f2b_options['retry_window'] = ($retry_window < 1) ? 1 : $retry_window;
$retry_window = ($retry_window < 1) ? 1 : $retry_window;
try { try {
$redis->Set('F2B_BAN_TIME', $ban_time); $redis->Set('F2B_OPTIONS', json_encode($f2b_options));
$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->Del('F2B_WHITELIST'); $redis->Del('F2B_WHITELIST');
if(!empty($wl)) { if(!empty($wl)) {
$wl_array = array_map('trim', preg_split( "/( |,|;|\n)/", $wl)); $wl_array = array_map('trim', preg_split( "/( |,|;|\n)/", $wl));

View File

@ -1134,13 +1134,13 @@ function get_logs($container, $lines = false) {
return $data_array; return $data_array;
} }
} }
if ($container == "fail2ban-mailcow") { if ($container == "netfilter-mailcow") {
if (!is_numeric($lines)) { if (!is_numeric($lines)) {
list ($from, $to) = explode('-', $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 { else {
$data = $redis->lRange('F2B_LOG', 0, intval($lines)); $data = $redis->lRange('NETFILTER_LOG', 0, intval($lines));
} }
if ($data) { if ($data) {
foreach ($data as $json_line) { foreach ($data as $json_line) {

View File

@ -3,7 +3,7 @@ function init_db_schema() {
try { try {
global $pdo; global $pdo;
$db_version = "27012018_1721"; $db_version = "30012018_1521";
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'"); $stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
@ -21,10 +21,6 @@ function init_db_schema() {
AND active = '1' AND active = '1'
AND address NOT LIKE '@%' AND address NOT LIKE '@%'
GROUP BY goto;", 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 "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 SELECT username, IFNULL(GROUP_CONCAT(local_part, '@', alias_domain SEPARATOR ' '), '') AS ad_alias FROM mailbox
LEFT OUTER JOIN alias_domain ON target_domain=domain 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'", "tls_enforce_out" => "TINYINT(1) NOT NULL DEFAULT '0'",
"kind" => "VARCHAR(100) NOT NULL DEFAULT ''", "kind" => "VARCHAR(100) NOT NULL DEFAULT ''",
"multiple_bookings" => "TINYINT(1) NOT NULL DEFAULT '0'", "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)", "created" => "DATETIME(0) NOT NULL DEFAULT NOW(0)",
"modified" => "DATETIME ON UPDATE CURRENT_TIMESTAMP", "modified" => "DATETIME ON UPDATE CURRENT_TIMESTAMP",
"active" => "TINYINT(1) NOT NULL DEFAULT '1'" "active" => "TINYINT(1) NOT NULL DEFAULT '1'"
@ -250,7 +245,8 @@ function init_db_schema() {
"eas_reset" => "TINYINT(1) NOT NULL DEFAULT '1'", "eas_reset" => "TINYINT(1) NOT NULL DEFAULT '1'",
"filters" => "TINYINT(1) NOT NULL DEFAULT '1'", "filters" => "TINYINT(1) NOT NULL DEFAULT '1'",
"quarantaine" => "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( "keys" => array(
"fkey" => array( "fkey" => array(

View File

@ -31,9 +31,9 @@ jQuery(function($){
e.preventDefault(); e.preventDefault();
draw_acme_logs(); draw_acme_logs();
}); });
$("#refresh_fail2ban_log").on('click', function(e) { $("#refresh_netfilter_log").on('click', function(e) {
e.preventDefault(); e.preventDefault();
draw_fail2ban_logs(); draw_netfilter_logs();
}); });
$("#refresh_rspamd_history").on('click', function(e) { $("#refresh_rspamd_history").on('click', function(e) {
e.preventDefault(); e.preventDefault();
@ -206,8 +206,8 @@ jQuery(function($){
} }
}); });
} }
function draw_fail2ban_logs() { function draw_netfilter_logs() {
ft_fail2ban_logs = FooTable.init('#fail2ban_log', { ft_netfilter_logs = FooTable.init('#netfilter_log', {
"columns": [ "columns": [
{"name":"time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}}, {"name":"time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}},
{"name":"priority","title":lang.priority,"style":{"width":"80px"}}, {"name":"priority","title":lang.priority,"style":{"width":"80px"}},
@ -215,10 +215,10 @@ jQuery(function($){
], ],
"rows": $.ajax({ "rows": $.ajax({
dataType: 'json', dataType: 'json',
url: '/api/v1/get/logs/fail2ban', url: '/api/v1/get/logs/netfilter',
jsonp: false, jsonp: false,
error: function () { error: function () {
console.log('Cannot draw fail2ban log table'); console.log('Cannot draw netfilter log table');
}, },
success: function (data) { success: function (data) {
return process_table_data(data, 'general_syslog'); return process_table_data(data, 'general_syslog');
@ -497,7 +497,7 @@ jQuery(function($){
draw_watchdog_logs(); draw_watchdog_logs();
draw_acme_logs(); draw_acme_logs();
draw_api_logs(); draw_api_logs();
draw_fail2ban_logs(); draw_netfilter_logs();
draw_rspamd_history(); draw_rspamd_history();
}); });

View File

@ -880,14 +880,14 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
echo '{}'; echo '{}';
} }
break; break;
case "fail2ban": case "netfilter":
// 0 is first record, so empty is fine // 0 is first record, so empty is fine
if (isset($extra)) { if (isset($extra)) {
$extra = preg_replace('/[^\d\-]/i', '', $extra); $extra = preg_replace('/[^\d\-]/i', '', $extra);
$logs = get_logs('fail2ban-mailcow', $extra); $logs = get_logs('netfilter-mailcow', $extra);
} }
else { else {
$logs = get_logs('fail2ban-mailcow'); $logs = get_logs('netfilter-mailcow');
} }
if (isset($logs) && !empty($logs)) { if (isset($logs) && !empty($logs)) {
echo json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); echo json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);

View File

@ -666,3 +666,14 @@ $lang['mailbox']['bcc_to_rcpt'] = "Map empfängerabhängig verwenden";
$lang['mailbox']['add_bcc_entry'] = "BCC-Eintrag hinzufügen"; $lang['mailbox']['add_bcc_entry'] = "BCC-Eintrag hinzufügen";
$lang['mailbox']['bcc_info'] = "Eine empfängerabhängige Map wird verwendet, wenn die BCC-Map Eintragung auf den Eingang einer E-Mail auf das lokale Ziel reagieren soll. Senderabhängige Maps verfahren nach dem gleichen Prinzip.<br/> $lang['mailbox']['bcc_info'] = "Eine empfängerabhängige Map wird verwendet, wenn die BCC-Map Eintragung auf den Eingang einer E-Mail auf das lokale Ziel reagieren soll. Senderabhängige Maps verfahren nach dem gleichen Prinzip.<br/>
Das lokale Ziel wird bei Fehlzustellungen an ein BCC-Ziel nicht informiert."; Das lokale Ziel wird bei Fehlzustellungen an ein BCC-Ziel nicht informiert.";
$lang['mailbox']['address_rewriting'] = 'Adressumschreibung';
$lang['mailbox']['recipient_maps'] = 'Empfängerumschreibungen';
$lang['mailbox']['recipient_map_info'] = 'Empfängerumschreibung ersetzen den Empfänger einer E-Mail vor dem Versand.';
$lang['mailbox']['recipient_map_old'] = 'Original Empfänger';
$lang['mailbox']['recipient_map_new'] = 'Neuer Empfänger';
$lang['mailbox']['add_recipient_map_entry'] = 'Empfängerumschreibung hinzufügen';
$lang['mailbox']['sender_maps'] = 'Senderumschreibungen';
$lang['mailbox']['sender_map_info'] = 'Senderumschreibungen werden verwendet, um den Absender einer E-Mail noch vor dem Versand umzuschreiben.';
$lang['mailbox']['sender_map_old'] = 'Original Absender';
$lang['mailbox']['sender_map_new'] = 'Neuer Absender';
$lang['mailbox']['add_sender_map_entry'] = 'Senderumschreibung hinzufügen';

View File

@ -667,3 +667,8 @@ $lang['mailbox']['recipient_map_info'] = 'Recipient maps are used to replace the
$lang['mailbox']['recipient_map_old'] = 'Original recipient'; $lang['mailbox']['recipient_map_old'] = 'Original recipient';
$lang['mailbox']['recipient_map_new'] = 'New recipient'; $lang['mailbox']['recipient_map_new'] = 'New recipient';
$lang['mailbox']['add_recipient_map_entry'] = 'Add recipient map'; $lang['mailbox']['add_recipient_map_entry'] = 'Add recipient map';
$lang['mailbox']['sender_maps'] = 'Sender maps';
$lang['mailbox']['sender_map_info'] = 'Sender maps are used to replace the sender address on a message before it is sent.';
$lang['mailbox']['sender_map_old'] = 'Original sender';
$lang['mailbox']['sender_map_new'] = 'New sender';
$lang['mailbox']['add_sender_map_entry'] = 'Add sender map';