Переглянути джерело

bugfix: "set last_found for ant arp records (with an unknown connection location)
html: add L3 interfaces for routers

Roman Dmitriev 1 рік тому
батько
коміт
80b6fbac1e

+ 3 - 1
html/admin/devices/edit_gw_subnets.php

@@ -41,7 +41,9 @@ print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login'
 <div id="contsubmenu">
 <br>
 <?php print "<form name=def action='edit_gw_subnets.php?id=".$id."' method=post>"; ?>
-<?php print WEB_list_gateway_subnets."<b>"; print_url($device['device_name'],"/admin/devices/editdevice.php?id=$id"); ?>
+<?php 
+if ($device['device_type'] == 0) { print WEB_list_l3_networks; } else { print WEB_list_gateway_subnets."<b>"; }
+print_url($device['device_name'],"/admin/devices/editdevice.php?id=$id"); ?>
 </b> <br>
 <table class="data">
 <tr align="center">

+ 2 - 1
html/admin/devices/editdevice.php

@@ -171,7 +171,8 @@ if ($device['device_type']==2) {
 if ($device['device_type']==0) {
     print "<tr><td>".WEB_device_dhcp_server."</td><td></td><td></td><td></td></tr>";
     print "<tr>";
-    print "<td class='data'>"; print_qa_select('f_dhcp', $device['dhcp']); print "</td><td></td><td></td><td></td>\n";
+    print "<td class='data'>"; print_qa_select('f_dhcp', $device['dhcp']); 
+    print "<td class='data' colspan=4>"; print_url(WEB_list_l3_networks,"/admin/devices/edit_gw_subnets.php?id=$id");
     print "</tr>\n";
     }
 

+ 1 - 0
html/inc/languages/english.php

@@ -336,6 +336,7 @@ define("WEB_nagios_template","Nagios Template");
 define("WEB_list_l3_interfaces","List of L3 interfaces");
 define("WEB_l3_interface_add","Add interface");
 define("WEB_list_gateway_subnets","List of subnets that work through the gateway");
+define("WEB_list_l3_networks","List of networks");
 
 /* editdevice */
 define("WEB_location_name","Location");

+ 2 - 0
html/inc/languages/russian.php

@@ -335,6 +335,8 @@ define("WEB_nagios_template","Шаблон Нагиос");
 define("WEB_list_l3_interfaces","Список L3 интерфейсов");
 define("WEB_l3_interface_add","Добавить интерфейс");
 define("WEB_list_gateway_subnets","Список подсетей, работающих через шлюз");
+define("WEB_list_l3_networks","Список терминируемых сетей");
+
 /* editdevice */
 define("WEB_location_name","Расположение");
 define("WEB_device_access_control","Управление доступом");

+ 25 - 6
scripts/fetch_new_arp.pl

@@ -110,6 +110,7 @@ my @authlist_ref = get_records_sql($dbh,"SELECT * FROM User_auth WHERE deleted=0
 
 my $users = new Net::Patricia;
 my %ip_list;
+my %oper_arp_list;
 
 foreach my $row (@authlist_ref) {
 $users->add_string($row->{ip},$row->{id});
@@ -142,9 +143,15 @@ foreach my $arp_table (@arp_array) {
         $arp_record->{ip_aton} = $ip_aton;
         $arp_record->{hotspot} = is_hotspot($dbh,$ip);
         my $cur_auth_id=resurrection_auth($dbh,$arp_record);
-        next if (!$cur_auth_id);
-        $mac_history{$simple_mac}{auth_id}=$cur_auth_id;
-        if ($auth_id ne $cur_auth_id) { $mac_history{$simple_mac}{changed}=1; }
+        if (!$cur_auth_id) { 
+	    db_log_warning($dbh,"Unknown record ".Dumper($arp_record));
+	    } else {
+            $mac_history{$simple_mac}{auth_id}=$cur_auth_id;
+	    $arp_record->{auth_id}=$cur_auth_id;
+	    $arp_record->{updated}=0;
+	    $oper_arp_list{$cur_auth_id}=$arp_record;
+	    if ($auth_id ne $cur_auth_id) { $mac_history{$simple_mac}{changed}=1; }
+	    }
     }
 }
 
@@ -344,7 +351,8 @@ foreach my $mac (keys %mac_address_table) {
                         if (exists $auth_table{oper_table}{$simple_mac}) {
                             my $auth_rec;
                             $auth_rec->{last_found}=$now_str;
-                                update_record($dbh,'User_auth',$auth_rec,"id=".$auth_id);
+			    $oper_arp_list{$auth_id}{updated}=1;
+                            update_record($dbh,'User_auth',$auth_rec,"id=".$auth_id);
                             }
                         next;
                         }
@@ -355,6 +363,7 @@ foreach my $mac (keys %mac_address_table) {
                     db_log_info($dbh,"Found auth_id: $auth_id ip: $mac_history{$simple_mac}{ip} [$mac_splitted] at device $dev_name [$port]. Update connection",$auth_id);
                     my $auth_rec;
                     $auth_rec->{last_found}=$now_str;
+		    $oper_arp_list{$auth_id}{updated}=1;
                     update_record($dbh,'User_auth',$auth_rec,"id=".$auth_id);
                     my $conn_rec;
                     $conn_rec->{port_id}=$port_id;
@@ -367,6 +376,7 @@ foreach my $mac (keys %mac_address_table) {
                     db_log_info($dbh,"Found auth_id: $auth_id ip: $mac_history{$simple_mac}{ip} [$mac_splitted] at device $dev_name [$port]. Create connection.",$auth_id);
                     my $auth_rec;
                     $auth_rec->{last_found}=$now_str;
+		    $oper_arp_list{$auth_id}{updated}=1;
                     update_record($dbh,'User_auth',$auth_rec,"id=".$auth_id);
                     my $conn_rec;
                     $conn_rec->{port_id}=$port_id;
@@ -398,15 +408,24 @@ foreach my $mac (keys %mac_address_table) {
     }
 }
 
+foreach my $auth_id (keys %oper_arp_list) {
+    next if ($oper_arp_list{$auth_id}->{updated});
+    my $auth_rec;
+    $auth_rec->{last_found}=$now_str;
+    update_record($dbh,'User_auth',$auth_rec,"id=".$auth_id);
+    db_log_debug($dbh,"Update by arp at unknown connect place for: ".Dumper($oper_arp_list{$auth_id})) if ($debug);
+}
+
 foreach my $mac (keys %mac_history) {
 next if (!$mac);
 next if (!$mac_history{$mac}->{changed});
 my $h_dev_id='';
-$h_dev_id=$mac_history{$mac}->{dev_id} if ($mac_history{$mac}->{dev_id});
 my $h_port_id='';
-$h_port_id=$mac_history{$mac}->{port_id} if ($mac_history{$mac}->{port_id});
 my $h_ip='';
+$h_dev_id=$mac_history{$mac}->{dev_id} if ($mac_history{$mac}->{dev_id});
+$h_port_id=$mac_history{$mac}->{port_id} if ($mac_history{$mac}->{port_id});
 $h_ip=$mac_history{$mac}->{ip} if ($mac_history{$mac}->{ip});
+
 my $h_auth_id=$mac_history{$mac}->{auth_id} if ($mac_history{$mac}->{auth_id});
 if (!$h_auth_id) { $h_auth_id=0; }
 next if (!$h_dev_id);