OpenWrt中wifidog的配置及各节点页面参数【转】

来源:互联网 发布:限制网速软件 编辑:程序博客网 时间:2024/05/22 06:49

来自:http://www.cnblogs.com/milton/p/6335414.html

修改/etc/wifidog.conf, 只需要修改文件的前半部分, 其他都保持默认

复制代码
GatewayID defaultGatewayInterface br-lanGatewayAddress 192.168.1.1AuthServer {    Hostname auth.mydomain.com    SSLAvailable no    HTTPPort 80    Path /wifidog/    LoginScriptPathFragment login.php?    PortalScriptPathFragment portal.php?    MsgScriptPathFragment message.php?    PingScriptPathFragment ping.php?    AuthScriptPathFragment auth.php?}
复制代码

其中
GatewayAddress wifidog所在路由的网关IP
Hostname: 提供验证服务的服务器
SSLAvailable, HTTPPort, Path 分别是验证服务对应的 是否可用https, 访问端口, 路径. 路径必须前后带'/'(如果是根目录则只有'/')
LoginScriptPathFragment 和上面的Path联合后得到的登录页地址
PortalScriptPathFragment 验证成功后的页面地址
MsgScriptPathFragment 消息页地址
PingScriptPathFragment 必须返回 Pong  --- 注意大小写一致
AuthScriptPathFragment 返回 Auth: 1 或 Auth: 0 代表验证通过/不通过

使用以下命令在前台启用wifidog, 可以看到详细的日志输出

wifidog -f

用户的访问顺序:

1. wifidog启动后, 会主动访问验证服务器

GET /wifidog/ping.php?gw_id=default&sys_uptime=11865&sys_memfree=70304&sys_load=0.77&wifidog_uptime=242 HTTP/1.0" 200 5 "-" "WiFiDog 1.3.0"

2. 用户连接wifi后, 会被引导至登录页

GET /wifidog/login.php?gw_address=192.168.1.1&gw_port=2060&gw_id=default&ip=192.168.1.110&mac=10:0b:a9:a6:bb:ac&url=http%3A%2F%2Fwww.bt.net%2Fframes.do HTTP/1.1

3. 用户登录成功后, 会返回wifidog的验证页, 其域名, 端口来自于前面的参数, 而/wifidog/auth?token= 这个是固定的

http://192.168.1.1:2060/wifidog/auth?token=128273kisdud71oidj12

4. wifidog会拿token去验证服务器验证

GET /wifidog/auth.php?stage=login&ip=192.168.1.110&mac=10:0b:a9:a6:bb:ac&token=1484935173&incoming=0&outgoing=0&gw_id=default HTTP/1.0" 200 8 "-" "WiFiDog 1.3.0"

5. 验证通过后, 用户浏览器再跳往 PortalScriptPathFragment 指定的地址

6. wifidog会定时去验证服务器验证访问有效性

GET /wifidog/auth.php?stage=counters&ip=192.168.1.110&mac=10:0b:a9:a6:bb:ac&token=1484935173&incoming=65954&outgoing=37750&gw_id=default HTTP/1.0" 200 8 "-" "WiFiDog 1.3.0"

 

一个登录页的例子

复制代码
<html><head>  <title>Login with Your Account</title></head><body><h2>Login</h2><?phpif (isset($_POST['user_name']) && isset($_POST['password'])) {  $user_name = $_POST['user_name'];  $password = $_POST['password'];  if ($user_name == 'milton' && $password == '123123') {    $location = 'Location: http://' . $_POST['gw_address'] . ':' . $_POST['gw_port'] .'/wifidog/auth?token='.time();    echo $location;    header($location);  } else {    echo '<h1>Incorrect login.</h1><br>';  }}?><form action="login.php" method="post">Username:<input type="text" name="user_name"/><br>Password:<input type="password" name="password"/><br><?phpecho '<input type="hidden" name="gw_address" value="'. $_GET['gw_address'] . '"><br>';echo '<input type="hidden" name="gw_port" value="'. $_GET['gw_port'] . '">';?><input type="submit"><pre><?php var_dump($_GET);?></pre></body></html>

原创粉丝点击