• OpenWrt中wifidog的配置及各节点页面参数


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

    GatewayID default
    GatewayInterface br-lan
    GatewayAddress 192.168.1.1
    AuthServer {
        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>
    <?php
    if (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>
    <?php
    echo '<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>
  • 相关阅读:
    WEB前端第六十二课——自封装Ajax、跨域、分页
    WEB前端第六十一课——xhr对象POST请求、xhr兼容性、timeout、progress
    WEB前端第六十课——原生Ajax与HTTP协议
    WEB前端第五十九课——时间戳、数据交互小案例
    考研日记录
    云栖大会day2 下午
    云栖大会day2总结 上午
    云栖大会day1 下午
    云栖大会day1 上午
    学习记录3
  • 原文地址:https://www.cnblogs.com/milton/p/6335414.html
Copyright © 2020-2023  润新知