Sfoglia il codice sorgente

mute resurrection email for hotspot

Dmitriev Roman 5 anni fa
parent
commit
e0f2d8f85e
2 ha cambiato i file con 19 aggiunte e 2 eliminazioni
  1. 2 0
      html/inc/common.php
  2. 17 2
      scripts/Rstat/mysql.pm

+ 2 - 0
html/inc/common.php

@@ -1293,6 +1293,7 @@ function new_auth($db, $ip, $mac, $user_id)
     if (!empty($resurrection_id)) {
     if (!empty($resurrection_id)) {
         apply_auth_rule($db,$resurrection_id,$user_id);
         apply_auth_rule($db,$resurrection_id,$user_id);
         if (!is_hotspot($db,$ip) and !empty($msg)) { LOG_WARNING($db, $msg); }
         if (!is_hotspot($db,$ip) and !empty($msg)) { LOG_WARNING($db, $msg); }
+        if (is_hotspot($db,$ip) and !empty($msg)) { LOG_INFO($db, $msg); }
         }
         }
     return $resurrection_id;
     return $resurrection_id;
 }
 }
@@ -1379,6 +1380,7 @@ function resurrection_auth($db, $ip, $mac, $action, $dhcp_hostname)
 	    $msg.="filter: ".$user_rec['filter_group_id']."\r\n queue_id: ".$user_rec['queue_id']."\r\n enabled: ".$user_rec['enabled']."\r\nid: $resurrection_id";
 	    $msg.="filter: ".$user_rec['filter_group_id']."\r\n queue_id: ".$user_rec['queue_id']."\r\n enabled: ".$user_rec['enabled']."\r\nid: $resurrection_id";
 	    }
 	    }
     if (!is_hotspot($db,$ip) and !empty($msg)) { LOG_WARNING($db, $msg); }
     if (!is_hotspot($db,$ip) and !empty($msg)) { LOG_WARNING($db, $msg); }
+    if (is_hotspot($db,$ip) and !empty($msg)) { LOG_INFO($db, $msg); }
     return $resurrection_id;
     return $resurrection_id;
 }
 }
 
 

+ 17 - 2
scripts/Rstat/mysql.pm

@@ -40,6 +40,7 @@ get_device_by_ip
 get_diff_rec
 get_diff_rec
 get_id_record
 get_id_record
 get_new_user_id
 get_new_user_id
+is_hotspot
 GetNowTime
 GetNowTime
 GetUnixTimeByStr
 GetUnixTimeByStr
 GetTimeStrByUnixTime
 GetTimeStrByUnixTime
@@ -438,6 +439,19 @@ return $now_str;
 
 
 #---------------------------------------------------------------------------------------------------------------
 #---------------------------------------------------------------------------------------------------------------
 
 
+sub is_hotspot {
+my $dbh = shift;
+my $ip  = shift;
+my $users = new Net::Patricia;
+#check hotspot
+my @ip_rules = get_records_sql($dbh,'SELECT * FROM subnets WHERE hotspot=1 AND LENGTH(subnet)>0');
+foreach my $row (@ip_rules) { $users->add_string($row->{subnet},$config_ref{hotspot_user_id}); }
+if ($users->match_string($ip)) { return 1; }
+return 0;
+}
+
+#---------------------------------------------------------------------------------------------------------------
+
 sub get_new_user_id {
 sub get_new_user_id {
 my $dbh = shift;
 my $dbh = shift;
 my $ip  = shift;
 my $ip  = shift;
@@ -694,11 +708,12 @@ $new_record->{dhcp_time}=$timestamp;
 if ($auth_exists) {
 if ($auth_exists) {
     #found ->Resurrection old record
     #found ->Resurrection old record
     my $resurrection_id = get_id_record($db,'User_auth',"ip_int=".$ip_aton." and mac='".$mac."'");
     my $resurrection_id = get_id_record($db,'User_auth',"ip_int=".$ip_aton." and mac='".$mac."'");
-    db_log_warning($db,"Resurrection auth_id: $resurrection_id with ip: $ip and mac: $mac");
+    if (!is_hotspot($db,$ip)) { db_log_warning($db,"Resurrection auth_id: $resurrection_id with ip: $ip and mac: $mac"); }
+	    else { db_log_info($db,"Resurrection auth_id: $resurrection_id with ip: $ip and mac: $mac"); }
     update_record($db,'User_auth',$new_record,"id=$resurrection_id");
     update_record($db,'User_auth',$new_record,"id=$resurrection_id");
     } else {
     } else {
     #not found ->create new record
     #not found ->create new record
-    db_log_warning($db,"New ip created! ip: $ip mac: $mac");
+    if (!is_hotspot($db,$ip)) { db_log_warning($db,"New ip created! ip: $ip mac: $mac"); } else { db_log_info($db,"New ip created! ip: $ip mac: $mac"); }
     insert_record($db,'User_auth',$new_record);
     insert_record($db,'User_auth',$new_record);
     }
     }
 #filter and status
 #filter and status