wifidog报错: Auth server did NOT say pong!

在wifidog启动过程中,我们可能会经常看到这种log:

Auth server did NOT say pong!

这个debug信息是再告诉我们,wifidog的ping协议没有收到来自auth server 的pong 回应。

首先解释下什么是ping协议。这种协议是路由器用来告诉auth server 路由器当前的状态,协议格式:

http://auth_server/ping/?gw_id=xxx&sys_uptime=xxx&sys_memfree&sys_load=xxx&wifidog_uptime=xxx

gw_id是路由器的标识符,sys_uptime是路由器启动时间,sys_memfree是路由器的内存剩余,sys_load是系统负载,wifidog_uptime是wifidog启动时间,路由器将这些信息发送给auth server,server 回"Pong" 来表示server知道这台路由器还在工作。

下面是出现上述log的代码:

do {

FD_ZERO(&readfds);

FD_SET(sockfd, &readfds);

timeout.tv_sec = 30; /* XXX magic... 30 second */

timeout.tv_usec = 0;

nfds = sockfd + 1;

nfds = select(nfds, &readfds, NULL, NULL, &timeout);

if (nfds > 0) {

/** We don't have to use FD_ISSET() because there

*  was only one fd. */

numbytes = read(sockfd, request + totalbytes, MAX_BUF - (totalbytes + 1));

if (numbytes < 0) {

debug(LOG_ERR, "An error occurred while reading from auth server: %s", strerror(errno));

/* FIXME */

close(sockfd);

return;

}

else if (numbytes == 0) {

done = 1;

}

else {

totalbytes += numbytes;

debug(LOG_DEBUG, "Read %d bytes, total now %d", numbytes, totalbytes);

}

}

else if (nfds == 0) {

debug(LOG_ERR, "Timed out reading data via select() from auth server");

/* FIXME */

close(sockfd);

return;

}

else if (nfds < 0) {

debug(LOG_ERR, "Error reading data via select() from auth server: %s", strerror(errno));

/* FIXME */

close(sockfd);

return;

}

} while (!done);

close(sockfd);

debug(LOG_DEBUG, "Done reading reply, total %d bytes", totalbytes);

request[totalbytes] = '\0';

debug(LOG_DEBUG, "HTTP Response from Server: [%s]", request);

if (strstr(request, "Pong") == 0) {

debug(LOG_WARNING, "Auth server did NOT say pong!");

/* FIXME */

}

else {

debug(LOG_DEBUG, "Auth Server Says: Pong");

}

这段log 出现在wifidog 在接收server 的响应包里没有出现Pong字符串。

本文章由 http://www.wifidog.pro/2015/02/25/wifidog%E7%9A%84ping%E5%8D%8F%E8%AE%AE.html 整理编辑,转载请注明出处

你可能感兴趣的:(wifidog报错: Auth server did NOT say pong!)