Declaration of originality
The source of this blog post is reproduced in the http://blog.csdn.net/zhujunxxxxx/article/details/25384909 hypothesis, please specify the source. This article author original, email [email protected], if you have any questions, please contact the author
Steps
1. First, simply talk about the process of WiFiDog certification
After the client first connects to WiFi. Browser requests 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 URL format such as the following:
/HTTP Gateway address: Gateway Port/wifidog/auth?token=
Wifidong initiates a thread that periodically reports status information for each user and sends it to the authentication through, for example, the following address
Server
Auth_server:/auth/?stage=
ip=
Mac=
token=
incoming=
outgoing=
The authentication server determines whether the user agrees to continue the connection and responds to the gateway in the form of: Auth: Status code, depending on the status information.
such as:auth:1
Use Status codes frequently:
0:auth_denied. Indicates rejection
1:auth_allowed, verify through
After validation passes. Redirect to the following address, for example:
Portal/?
gw_id=%s
Ping protocol for WiFiDog
The WiFiDog sends the current status information to the authentication server through the ping protocol. The sending address is:
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.
Detailed PHP implementation code such as the following
Public Function auth () {//respond to the client's timing authentication, where you can do various statistics, billing, etc./* WiFiDog will pass the connection client information through this interface. Then the basis is returned. The client does open, disconnect and so on, the detailed return value can see WiFiDog document WiFiDog main submissions such as the following parameters 1.ip 2. Mac 3. Token (token from login page) 4.incoming download traffic 5.outgoing upload traffic 6.stage authentication phase, on both login and counters */$stage = $_get[' stage '] = = ' counters '?' Counters ': ' Login '; if ($stage = = ' Login ') {//xxxx Skip login phase of processing XXXX can not skip the//default return consent echo "Auth:1"; } else if ($stage = = ' counters ') {//do a simple traffic inference verification, when downloading traffic value, return to the offline notification, otherwise remain 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 Deny/* return value: There are two main things that are enough. 0-Reject 1-release official documents such as the following 0-auth_denied-user firewall users a Re 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 shuts down the 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 (when user email is verified, open email to users) -1-auth_error-an ERROR occurred during the Validat Ion process */} public Function portal () {/* WiFiDog the number of references brought over such as the following 1. gw_id *///re-set toSpecify the site or display Splash AD page redirect (' http://www.baidu.com ', ' location ', 302); 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)); Infer 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 }//Join the Heartbeat log processing function/* Here to get WIFIFOG provided for example the following 1.gw_id from WiFiDog configuration file, to distinguish between different routing devices 2.sys_uptime router system boot time 3 . Sys_memfree system memory Usage percentage 4.wifidog_uptime wifidog continuous Execution time (this data is often problematic) *///return value echo ' Pong '; }/** * WiFiDog's Gw_message interface. Information Tip page */function Gw_message () {if (Isset ($_request["message")) {switch ($_request["message"]) {CA Se ' failEd_validation '://auth's stage is login. When the server returns to Auth_validation_failed, it comes to the place to process//authentication failed. Please again certification break; Case ' denied ': When//auth's stage is login, it is returned to auth_denied by the server. came to the place processing//certification was refused break; Case ' activate ': When//auth's stage is login, it is returned to Auth_validation by the server. Come to the place to process//pending activation of the break; Default:break; }}else{//Do not echo whatever information}}
WiFiDog implementation of validation process with PHP