查看: 3388|回复: 0

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

[复制链接]
  • TA的每日心情
    擦汗
    2014-2-12 10:49
  • 签到天数: 150 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2017-8-1 09:46:58 | 显示全部楼层 |阅读模式
    分享到:
    修改/etc/wifidog.conf, 只需要修改文件的前半部分, 其他都保持默认
    1. GatewayID default
    2. GatewayInterface br-lan
    3. GatewayAddress 192.168.1.1
    4. AuthServer {
    5.     Hostname auth.mydomain.com
    6.     SSLAvailable no
    7.     HTTPPort 80
    8.     Path /wifidog/
    9.     LoginScriptPathFragment login.php?
    10.     PortalScriptPathFragment portal.php?
    11.     MsgScriptPathFragment message.php?
    12.     PingScriptPathFragment ping.php?
    13.     AuthScriptPathFragment auth.php?
    14. }
    复制代码
    其中
    GatewayAddress wifidog所在路由的网关IP
    Hostname: 提供验证服务的服务器
    SSLAvailable, HTTPPort, Path 分别是验证服务对应的 是否可用https, 访问端口, 路径. 路径必须前后带'/'(如果是根目录则只有'/')
    LoginScriptPathFragment 和上面的Path联合后得到的登录页地址
    PortalScriptPathFragment 验证成功后的页面地址
    MsgScriptPathFragment 消息页地址
    PingScriptPathFragment 必须返回 Pong  --- 注意大小写一致
    AuthScriptPathFragment 返回 Auth: 1 或 Auth: 0 代表验证通过/不通过
    使用以下命令在前台启用wifidog, 可以看到详细的日志输出
    1. wifidog -f
    复制代码
    用户的访问顺序:
    1. wifidog启动后, 会主动访问验证服务器
    1. 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后, 会被引导至登录页
    1. 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= 这个是固定的
    1. http://192.168.1.1:2060/wifidog/auth?token=128273kisdud71oidj12
    复制代码
    4. wifidog会拿token去验证服务器验证
    1. 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会定时去验证服务器验证访问有效性
    1. 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"
    复制代码
    一个登录页的例子
    1. <html>
    2. <head>
    3.   <title>Login with Your Account</title>
    4. </head>
    5. <body>
    6. <h2>Login</h2>
    7. <?php
    8. if (isset($_POST['user_name']) && isset($_POST['password'])) {
    9.   $user_name = $_POST['user_name'];
    10.   $password = $_POST['password'];

    11.   if ($user_name == 'milton' && $password == '123123') {
    12.     $location = 'Location: http://' . $_POST['gw_address'] . ':' . $_POST['gw_port'] .'/wifidog/auth?token='.time();
    13.     echo $location;
    14.     header($location);
    15.   } else {
    16.     echo '<h1>Incorrect login.</h1>
    17. ';
    18.   }
    19. }
    20. ?>
    21. <form action="login.php" method="post">
    22. Username:<input type="text" name="user_name"/>

    23. Password:<input type="password" name="password"/>

    24. <?php
    25. echo '<input type="hidden" name="gw_address" value="'. $_GET['gw_address'] . '">
    26. ';
    27. echo '<input type="hidden" name="gw_port" value="'. $_GET['gw_port'] . '">';
    28. ?>
    29. <input type="submit">
    30. <pre>
    31. <?php var_dump($_GET);?>
    32. </pre>
    33. </body>
    34. </html>
    复制代码
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-4-17 03:13 , Processed in 0.133271 second(s), 17 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.