mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 02:17:58 +00:00 
			
		
		
		
	uspot: accounting: allow radius calls from non-clients
In order to send RADIUS accounting requests at the NAS level (for e.g. Accounting-On/Off), radius_init() and radius_call() are made to accept a null mac argument. For radius_call() we fall back to the acct_session value (which is required to be present per RFC) to construct the temporary file name. 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
						
							97f641a16b
						
					
				
				
					commit
					a647368f15
				
			| @@ -49,24 +49,26 @@ function debug(interface, mac, msg) { | ||||
| } | ||||
|  | ||||
| function radius_init(interface, mac, payload) { | ||||
| 	let client = interfaces[interface].clients[mac]; | ||||
| 	let settings = interfaces[interface].settings; | ||||
|  | ||||
| 	payload.acct_server = sprintf('%s:%s:%s', settings.acct_server, settings.acct_port, settings.acct_secret); | ||||
| 	payload.nas_id = settings.nas_id; | ||||
|  | ||||
| 	for (let key in [ 'acct_session', 'client_ip', 'called_station', 'calling_station', 'nas_ip', 'username', 'location_name' ]) | ||||
| 		if (client.radius[key]) | ||||
| 			payload[key] = client.radius[key]; | ||||
|  | ||||
| 	if (settings.acct_proxy) | ||||
| 		payload.acct_proxy = settings.acct_proxy; | ||||
|  | ||||
| 	if (mac) { | ||||
| 		// dealing with client accounting | ||||
| 		let client = interfaces[interface].clients[mac]; | ||||
| 		for (let key in [ 'acct_session', 'client_ip', 'called_station', 'calling_station', 'nas_ip', 'username', 'location_name' ]) | ||||
| 			if (client.radius[key]) | ||||
| 				payload[key] = client.radius[key]; | ||||
| 	} | ||||
|  | ||||
| 	return payload; | ||||
| } | ||||
|  | ||||
| function radius_call(interface, mac, payload) { | ||||
| 	let path = '/tmp/uacct' + mac + '.json'; | ||||
| 	let path = '/tmp/uacct' + (mac || payload.acct_session) + '.json'; | ||||
| 	let cfg = fs.open(path, 'w'); | ||||
| 	cfg.write(payload); | ||||
| 	cfg.close(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user