Iptables.php
[Pman.Admin] / Iptables.php
index f68bafc..4ef2ac2 100644 (file)
@@ -321,7 +321,11 @@ class Pman_Admin_Iptables extends Pman {
         
         // remove rules that need deleting..
         foreach($remove as $ip => $r) {
-            $this->exec("{$iptables} -D postgres {$r['num']} ");
+            
+            $this->removeIp($ip);
+            
+            
+           //$this->exec("{$iptables} -D postgres {$r['num']} ");
             
         }
         
@@ -331,6 +335,24 @@ class Pman_Admin_Iptables extends Pman {
         
     }
     
+    function removeIp($ip)
+    {
+        // we need to scan the list each time, as the order get's renumbbered when we remove wone...
+        $ar = $this->readChain('postgres');
+        foreach($ar as $row) {
+            if ($row['target'] != 'ACCEPT') {
+                continue;
+            }
+            
+            if ($row['source'] != $ip) {
+                continue;
+            }
+            $this->exec("{$iptables} -D postgres {$row['num']} ");
+            break;
+        }
+    }
+    
+    
     
     function createBase()
     {