mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-30 18:07:52 +00:00 
			
		
		
		
	uspot: accounting: fix loop logic
When looping through known clients: - removal of client in spotfilter list is checked first - checks for known client existence are redundant by construction Also format the max_total check similarly to the timeout one Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
		 Thibaut VARÈNE
					Thibaut VARÈNE
				
			
				
					committed by
					
						 John Crispin
						John Crispin
					
				
			
			
				
	
			
			
			 John Crispin
						John Crispin
					
				
			
						parent
						
							c6d07ca178
						
					
				
				
					commit
					245b062db8
				
			| @@ -231,39 +231,35 @@ function accounting(interface) { | |||||||
| 			client_add(interface, mac, payload); | 			client_add(interface, mac, payload); | ||||||
|  |  | ||||||
| 	for (let mac in clients[interface]) { | 	for (let mac in clients[interface]) { | ||||||
| 		if (list[mac].data?.logoff) { |  | ||||||
| 			radius_logoff(interface, mac); |  | ||||||
| 			client_flush(interface, mac, 'logoff event'); |  | ||||||
| 			continue; |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		if (!list[mac] || !list[mac].state) { | 		if (!list[mac] || !list[mac].state) { | ||||||
| 			radius_disconnect(interface, mac); | 			radius_disconnect(interface, mac); | ||||||
| 			client_remove(interface, mac, 'disconnect event'); | 			client_remove(interface, mac, 'disconnect event'); | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		if (list[mac].data.logoff) { | ||||||
|  | 			radius_logoff(interface, mac); | ||||||
|  | 			client_flush(interface, mac, 'logoff event'); | ||||||
|  | 			continue; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		if (list[mac].idle > get_idle_timeout(interface, mac)) { | 		if (list[mac].idle > get_idle_timeout(interface, mac)) { | ||||||
| 			if (clients[interface][mac]) |  | ||||||
| 			radius_idle_time(interface, mac); | 			radius_idle_time(interface, mac); | ||||||
| 			client_remove(interface, mac, 'idle event'); | 			client_remove(interface, mac, 'idle event'); | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
| 		let timeout = get_session_timeout(interface, mac); | 		let timeout = get_session_timeout(interface, mac); | ||||||
| 		if (timeout && ((t - list[mac].data.connect) > timeout)) { | 		if (timeout && ((t - list[mac].data.connect) > timeout)) { | ||||||
| 			if (clients[interface][mac]) |  | ||||||
| 			radius_session_time(interface, mac); | 			radius_session_time(interface, mac); | ||||||
| 			client_flush(interface, mac, 'session timeout'); | 			client_flush(interface, mac, 'session timeout'); | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
| 		if (clients[interface][mac].max_total) { | 		let maxtotal = +clients[interface][mac].max_total; | ||||||
| 			let total = list[mac].bytes_ul + list[mac].bytes_dl; | 		if (maxtotal && ((list[mac].bytes_ul + list[mac].bytes_dl) >= maxtotal)) { | ||||||
| 			if (total >= clients[interface][mac].max_total) { |  | ||||||
| 			radius_session_time(interface, mac); | 			radius_session_time(interface, mac); | ||||||
| 			client_flush(interface, mac, 'max octets reached'); | 			client_flush(interface, mac, 'max octets reached'); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
| } | } | ||||||
|  |  | ||||||
| uloop.init(); | uloop.init(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user