1. First of all, simply talk about the process of WiFiDog certification
Once the client connects to WiFi for the first time, the browser request will be redirected to:
login/?gw_address=%s&gw_port=%d&gw_id=%s&url=%s
After validation is passed, the client is redirected to the gateway with the following URL format:
http://gateway address: Gateway Port/WIFIDOG/AUTH?TOKEN=XX,
Wifidong initiates a thread that periodically reports the status information of each user and sends it to the authentication server via the following address:
Auth_server:/auth/?stage=
ip=
Mac=
token=
incoming=
outgoing=
According to the status information, the authentication server decides whether to allow the user to continue connecting and reply to the Gateway, the reply format is: Auth: status Code,
such as: auth:1
Common status Code:
0:auth_denied, refusing to say
1:auth_allowed, verify through
After validation is passed, it is redirected to the following address:
portal/?gw_id=%s
Ping protocol for WiFiDog:
WiFiDog sends the current status information to the authentication server by ping protocol, sending the address:
http://auth_sever/ping/?
gw_id=%s
Sys_uptime=%lu
Sys_memfree=%u
sys_load=%.2f
Wifidog_uptime=%lu
The authentication server must return a "Pong" as a response.
The specific PHP implementation code is as follows
Public Function auth () {//response to the client's timing certification, where you can do a variety of statistics, billing and so on/* WiFiDog will pass this interface to connect the client information, and then according to the return, the client do open, disconnected, etc. processing, specific return The return value can be seen WiFiDog document WiFiDog mainly submitted as follows parameter 1.ip 2. Mac 3.
Token (Login page issued token) 4.incoming download traffic 5.outgoing upload Traffic 6.stage certification phase, on two types of login and counters * * $stage = $_get[' stage '] = = ' counters '?
Counters ': ' Login ';
if ($stage = = ' Login ') {//xxxx Skip login phase processing XXXX can not casually skip//default return Allow echo "auth:1"; else if ($stage = = ' counters ') {//do a simple traffic judgment verification, download flow value, return to the offline notification, otherwise keep online if (!empty ($_get[' incoming ')
) and $_get[' incoming '] > 10000000) {echo "auth:0";
}else{echo "auth:1\n"; } else echo "auth:0"; All other cases return the Reject/* return value: There are two main things that are enough. 0-Reject 1-release official documents as follows 0-
Auth_denied-user firewall users are deleted and the User removed. 6-Auth_validation_failed-user Email VALIDATION timeout has occured and User/firewall is deleted (User message authentication timed out, firewall shutdown that user) 1-auth_allowed-user is valid, add firewall rules if not present 5-auth_validation-permit User Access to email to get validation email under default rules (user email verification when opening email to user) -1-auth_error-an ERROR OC Curred during the validation process/} public Function portal () {/* WiFiDog with the following parameters: 1.
GW_ID//re-set to the designated website or display splash AD page redirect (' http://www.baidu.com ', ' location ', 302); The Public Function ping () {//url request gw_id= $GW _id&sys_uptime= $sys _uptime&sys_memfree= $sys _memfree&sys_
load= $sys _load&wifidog_uptime= $wifidog _uptime "; Log_message ($this->config->item (' My_log_threshold '), __class__. ': __function__. ': Debug_printarray ($_
Get)); Determine whether the various parameters are empty if (!) ( Isset ($_get[' gw_id ']) and isset ($_get[' sys_uptime ']) and isset ($_get[' Sys_memfree ']) and isset ($_get[' Sys_load ']) and isset ($_get[' wifidog_uptime '))) {echo ' {' Error ': ' 2 '} ';
Return //Add heartbeat log processing//* Here you can get the following parameters provided by Wififog 1.gw_id from the WiFiDog configuration file to differentiate between different routing devices 2.sys_uptime Router's system boot time 3.sys_memfree system memory usage percentage 4.wifidog_uptime wifidog duration (this data is often problematic) *//return value echo '
Pong '; /** * WiFiDog Gw_message interface, information prompt page */function Gw_message () {if (Isset ($_request["message")) {switch ($_request["message"])
{case ' failed_validation '://auth's stage for login, when the server returned auth_validation_failed, came to the place to handle
Authentication failed, please re-authenticate the break;
Case ' denied '://auth's stage for login, when the server returned to Auth_denied, came to the place processing//certification was refused to break;
Case ' activate ': When//auth's stage is login, when the server returns Auth_validation, it comes to the place to process//BE activated
Break
Default:break; }else{//Do not echo any information}}