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?判斷處改成當前時間減去上線時間即可。
本文章由