默认的的wifidog认证页面跳转url是这样的
login/?gw_address=%s&gw_port=%d&gw_id=%s&url=%s
Example: https://auth.ilesansfil.org/login/?gw_id=0016B6DA9AE0&gw_address=7.0.0.1&gw_port=2060
由于业务需要,需要在跳转到认证页面时加一个客户端内网IP地址,即ClienIPAddress
下载wifidog添代码,打开http.c,找到
/* Re-direct them to auth server */
char *urlFragment;
safe_asprintf(&urlFragment, "%sgw_address=%s&gw_port=%d&gw_id=%s&url=%s",
auth_server->authserv_login_script_path_fragment,
config->gw_address,
config->gw_port,
config->gw_id,
url);
debug(LOG_INFO, "Captured %s requesting [%s] and re-directing them to login page", r->clientAddr, url);
http_send_redirect_to_auth(r, urlFragment, "Redirect to login page");
free(urlFragment);
修改为
/* Re-direct them to auth server */
char *urlFragment;
char *mac = arp_get(r->clientAddr);
if(!mac)
{
printf("mac cannot get\n");
return;
}
safe_asprintf(&urlFragment, "%sgw_address=%s&gw_port=%d&gw_id=%s&url=%s&clientip=%s&clientmac=%s",
auth_server->authserv_login_script_path_fragment,
config->gw_address,
config->gw_port,
config->gw_id,
url,
r->clientAddr,
mac);
debug(LOG_INFO, "Captured %s requesting [%s] and re-directing them to login page", r->clientAddr, url);
http_send_redirect_to_auth(r, urlFragment, "Redirect to login page");
free(urlFragment);
重新编译以后就OK了
现在认证跳转url就带有客户端ip地址了
http://authServer/login/?gw_address=10.0.0.254&gw_port=2060&gw_id=79194CFB58&url=http%3A//www.baidu.com&clientAddr=10.0.0.100&clientmac=00:23:43:a3:b1:d5
本文由http://www.wifidog.pro/2014/12/10/wifidog-login%E5%8D%8F%E8%AE%AE%E6%B7%BB%E5%8A%A0%E5%AE%A2%E6%88%B7%E7%AB%AFIP-MAC.html整理编辑,转载请注明出处