RADIUSdesk

logo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
radiusdesk:radius_clients:disconnect [2023/01/03 07:39]
admin [Mikrotik]
radiusdesk:radius_clients:disconnect [2023/01/03 08:25] (current)
admin
Line 27: Line 27:
 ==== Mikrotik ==== ==== Mikrotik ====
   * With the Mikrotik RADIUS Clients we make use of the **RouterOS API Client** to communicate with the Mikrotik. (https://github.com/EvilFreelancer/routeros-api-php)   * With the Mikrotik RADIUS Clients we make use of the **RouterOS API Client** to communicate with the Mikrotik. (https://github.com/EvilFreelancer/routeros-api-php)
-  * This is already included with RADIUSdesk.+  * This library is already included with RADIUSdesk.
   * Many times there will be a NAT connection between the Mikrotik and the RADIUSdesk server preventing the server to reach the Mikrotik directly.   * Many times there will be a NAT connection between the Mikrotik and the RADIUSdesk server preventing the server to reach the Mikrotik directly.
   * Mikrotik fortunately supports a large amount of VPN technologies which you can choose from.   * Mikrotik fortunately supports a large amount of VPN technologies which you can choose from.
Line 35: Line 35:
  
   * There is also a **Test API Connection** button which allows you to confirm that the API communication to the Mikrotik is indeed working.   * There is also a **Test API Connection** button which allows you to confirm that the API communication to the Mikrotik is indeed working.
-  * In the screenshot above you can se part of the reply from the Mikrotik indicating that the communication via the API is established and good. +  * In the screenshot above you can see part of the reply from the Mikrotik indicating that the communication via the API is established and good. 
-  * We also added an Mikrotik API button to the +  * We also added Mikrotik API button to the toolbar for RADIUS Clients. 
 +{{:radiusdesk:radius_clients:radius_client_api_button.png?nolink|}} 
 + 
 +  * The button is disabled by default and becomes enabled when you select a RADIUS Client of type **Mikrotik-API**. 
 +  * Selecting it will open a new tab with two sub-tabs. One listing active **Hotspot** users and the other listing active **PPPoE** users. 
 +  * You can select and disconnect listed users in those sub-tabs. 
 +{{:radiusdesk:radius_clients:radius_client_api_tab.png?nolink|}} 
 + 
 +===== Add Support for additional types ===== 
 +  * This section is a technical section for those who wants to introduce new RADIUS Client types. 
 +  * The list in the drop-down is specified in the following file: ///var/www/rdcore/cake4/rd_cake/config/RadiusDesk.php// 
 +<code php> 
 +//Define nas types 
 +$config['nas_types'][0]     = ['name' => 'Other',            'id' => 'other',        'active' => true]; 
 +$config['nas_types'][1]     = ['name' => 'Coova-On-Meshdesk', 'id' => 'CoovaMeshdesk',    'active' => true]; 
 +$config['nas_types'][2]     = ['name' => 'Mikrotik-API', 'id' => 'Mikrotik-API',    'active' => true]; 
 +</code> 
 +  * Then when selecting an active user in **Activity Monitor** to disconnect behind the scenes the code will determine the type of RADIUS  Client based on the **nasidentifier** field. (This is in the radacct table and has to match the value in the dynamic-clients table) 
 +  * This all happens inside the ///var/www/rdcore/cake4/rd_cake/src/Controller/Component/KickerComponent.php// file. 
 +  * Thus adding support for additional types will involve adding additional sections to the PHP code. 
 +  * See the snippet below. 
 +<code php> 
 +//First we try to locate the client under dynamic_clients 
 +$dc = $this->DynamicClients->find() 
 + ->where(['DynamicClients.nasidentifier' => $nasidentifier]) 
 + ->contain(['DynamicClientSettings']) 
 + ->first(); 
 +  
 +if($dc){ 
 + //===CoovaMeshdesk==== 
 + if($dc->type == $this->coova_md){ //It is type CoovaMeshdesk => Now try and locate AP to send command to  
 +  
 + //We have a convention of nasidentifier for meshdesk => mcp_<captive_portal_id> and apdesk => ap_<ap id>_cp_<captive_portal_id> 
 + if(preg_match('/^mcp_/' ,$nasidentifier)){ //MESHdesk       
 + $this->kickMeshNodeUser($ent,$dc->cloud_id,$token); 
 +
 +  
 + if(preg_match('/^ap_/' ,$nasidentifier)){ //APdesk  
 + $this->kickApUser($ent,$dc->cloud_id,$token);  
 +
 + sleep(1); //Give MQTT time to do its thing....   
 +
 +      
 + //===Mikrotik-API=== 
 + 
 +</code> 
 +  * That's the only things involved in disconnecting an active RADIUS user. 
 +  * The FUP implementation also utilizes this mechanism so this also serve as a core component for the FUP implementation to be successful.