wifidog如何判断用户不在线?

wifidog如何判断用户不在线?

if (p1->counters.last_updated +

                       (config->checkinterval * config->clienttimeout) 

                       <= current_time) {

        /* Timing out user */

        debug(LOG_INFO, "%s - Inactive for more than %ld seconds, removing client and denying in firewall",

                p1->ip, config->checkinterval * config->clienttimeout);

        fw_deny(p1->ip, p1->mac, p1->fw_connection_state);

        client_list_delete(p1);

         /* Advertise the logout if we have an auth server */

        if (config->auth_servers != NULL) {

                                UNLOCK_CLIENT_LIST();

                                auth_server_request(&authresponse, REQUEST_TYPE_LOGOUT, ip, mac, token, 0, 0);

                                LOCK_CLIENT_LIST();

        }

wifidog发送logout 请求的地方一个是客户端主动触发wifidog下线请求,另一个就在上述代码所述。
这段代码主要是用来判断客户端是否在一定时间内没上网,如果是,wifidog会将其踢出,然后告诉服务器这个客户端已经下线了。

这里可以改成客户端连接一段时间后再踢下线,同样可以改成发现用户没有连接路由器直接踢下线,后者需要用到arp 包来ping 客户端,前者只要在客户端连接之后加个上线时间再在上述代码的if 判断处改成当前时间减去上线时间即可。

本文章由 http://www.wifidog.pro/2015/03/25/wifidog%E5%A6%82%E4%BD%95%E5%88%A4%E6%96%AD%E7%94%A8%E6%88%B7%E4%B8%8D%E5%9C%A8%E7%BA%BF.html 整理编辑,转载请注明出处

原文地址:https://www.cnblogs.com/wifidog/p/4364876.html