Selaa lähdekoodia

[Web] Fix return for unban/ban actions via API

andryyy 6 vuotta sitten
vanhempi
sitoutus
b74226a9dc
1 muutettua tiedostoa jossa 16 lisäystä ja 0 poistoa
  1. 16 0
      data/web/inc/functions.fail2ban.inc.php

+ 16 - 0
data/web/inc/functions.fail2ban.inc.php

@@ -113,6 +113,14 @@ function fail2ban($_action, $_data = null) {
                 $redis->hDel('F2B_BLACKLIST', $network, 1);
                 $redis->hDel('F2B_BLACKLIST', $network, 1);
                 $redis->hSet('F2B_QUEUE_UNBAN', $network, 1);
                 $redis->hSet('F2B_QUEUE_UNBAN', $network, 1);
               }
               }
+              else  {
+                $_SESSION['return'][] = array(
+                  'type' => 'danger',
+                  'log' => array(__FUNCTION__, $_action, $_data_log),
+                  'msg' => array('network_host_invalid', $network)
+                );
+                continue;
+              }
             }
             }
             elseif ($_data['action'] == "blacklist") {
             elseif ($_data['action'] == "blacklist") {
               if (valid_network($network)) {
               if (valid_network($network)) {
@@ -120,6 +128,14 @@ function fail2ban($_action, $_data = null) {
                 $redis->hDel('F2B_WHITELIST', $network, 1);
                 $redis->hDel('F2B_WHITELIST', $network, 1);
                 $response = docker('post', 'netfilter-mailcow', 'restart');
                 $response = docker('post', 'netfilter-mailcow', 'restart');
               }
               }
+              else  {
+                $_SESSION['return'][] = array(
+                  'type' => 'danger',
+                  'log' => array(__FUNCTION__, $_action, $_data_log),
+                  'msg' => array('network_host_invalid', $network)
+                );
+                continue;
+              }
             }
             }
           }
           }
           catch (RedisException $e) {
           catch (RedisException $e) {