Procházet zdrojové kódy

bugfix: fixed illegal port mapping in analyze mac-table by snmp, introduced after mikrotik patch

root před 3 roky
rodič
revize
03eacbdeaf

+ 1 - 1
html/admin/logs/authlog.php

@@ -35,7 +35,7 @@ if ($log_level == $L_ERROR) { $log_filter = " and (`level`=$L_INFO or `level`=$L
 if ($log_level == $L_VERBOSE) { $log_filter = " and (`level`=$L_INFO or `level`=$L_ERROR or `level`=$L_VERBOSE) "; }
 if ($log_level == $L_DEBUG) { $log_filter = ""; }
 
-if (!empty($log_filter)) { $log_filter = $log_filter." and auth_id=".$auth_id; } else { $log_filter = "auth_id=".$auth_id; }
+if (!empty($log_filter)) { $log_filter = $log_filter." and auth_id=".$auth_id; } else { $log_filter = " and auth_id=".$auth_id; }
 if (!empty($fcustomer)) { $log_filter = $log_filter." and customer LIKE '%".$fcustomer."%'"; }
 if (!empty($fmessage)) { $log_filter = $log_filter." and message LIKE '%".$fmessage."%'"; }
 

+ 8 - 4
html/inc/common.php

@@ -1820,11 +1820,16 @@ if (isset($index_table) and count($index_table) > 0 and isset($is_mikrotik)) {
                 }
             }
         } else {
-        $index_table =  walk_snmp($ip, $community, $version, $ifmib_ifindex);
+#        $index_table =  walk_snmp($ip, $community, $version, $ifmib_ifindex);
         if (isset($index_table) and count($index_table) > 0) {
             foreach ($index_table as $key => $value) {
-                $value = intval(trim(str_replace('INTEGER:', '', $value)));
-                $ifmib_map[$value]=$value;
+                $key = trim($key);
+	        $value = intval(trim(str_replace('INTEGER:', '', $value)));
+    	        $result = preg_match('/\.(\d{1,10})$/',$key,$matches);
+        	if ($result) {
+            	        $int_index = preg_replace('/^\./', '', $matches[0]);
+            		$ifmib_map[$int_index]=$int_index;
+            		}
                 }
             }
         }
@@ -1949,7 +1954,6 @@ function get_fdb_table($ip, $community, $version)
 
     $fdb1_port_table = get_mac_table($ip, $community, $version, $mac_table_oid2, $ifindex_map);
     $fdb2_port_table = get_mac_table($ip, $community, $version, $mac_table_oid, $ifindex_map);
-
     if (!empty($fdb1_port_table)) { $fdb_port_table = $fdb1_port_table; }
     if (!empty($fdb2_port_table)) {
         if (empty($fdb_port_table)) {

+ 0 - 2
html/inc/idfilter.php

@@ -3,8 +3,6 @@ if (! defined("CONFIG")) die("Not defined");
 
 if (empty($id) and !empty($_SESSION[$page_url]['id'])) { $id = $_SESSION[$page_url]['id']; }
 
-if (empty($id) and !empty($default_id)) { $id=$default_id; }
-
 if (empty($id)) {
     header("Location: /admin/index.php");
     exit;

+ 8 - 5
scripts/Rstat/snmp.pm

@@ -216,13 +216,16 @@ if (%$index_table and $is_mikrotik) {
         	}
 	    }
         } else {
-        $index_table =  snmp_get_oid($ip, $community, $ifIndex, $version);
-        if (!%$index_table) { $index_table =  snmp_walk_oid($ip, $community, $ifIndex, $version); }
+#        $index_table =  snmp_get_oid($ip, $community, $ifIndex, $version);
+#        if (!%$index_table) { $index_table =  snmp_walk_oid($ip, $community, $ifIndex, $version); }
         if (%$index_table) {
             foreach my $row (keys(%$index_table)) {
-                my $port_index = $index_table->{$row};
-                next if (!$port_index);
-                $ifmib_map->{$port_index}=$port_index;
+	        my $port_index = $index_table->{$row};
+	        next if (!$port_index);
+        	my $value;
+                if ($row=~/\.([0-9]{1,10})$/) { $value = $1; }
+	        next if (!$value);
+    	        $ifmib_map->{$value}=$value;
                 };
             }
         }