OpenWrt中wifidog的配置及各节点页面参数
2023-03-07 09:41:52 时间
修改/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>
相关文章
- 在 Go 里用 CGO?这 7 个问题你要关注!
- 9款优秀的去中心化通讯软件 Matrix 的客户端
- 求职数据分析,项目经验该怎么写
- 在OKR中,我看到了数据驱动业务的未来
- 火山引擎云原生大数据在金融行业的实践
- OpenHarmony富设备移植指南(二)—从postmarketOS获取移植资源
- 《数据成熟度指数》报告:64%的企业领袖认为大多数员工“不懂数据”
- OpenHarmony 小型系统兼容性测试指南
- 肯睿中国(Cloudera):2023年企业数字战略三大趋势预测
- 适用于 Linux 的十大命令行游戏
- GNOME 截图工具的新旧截图方式
- System76 即将推出的 COSMIC 桌面正在酝酿大变化
- 2GB 内存 8GB 存储即可流畅运行,Windows 11 极致精简版系统 Tiny11 发布
- 迎接 ecode:一个即将推出的具有全新图形用户界面框架的现代、轻量级代码编辑器
- loongarch架构介绍(三)—地址翻译
- Go 语言怎么解决编译器错误“err is shadowed during return”?
- 敏捷:可能被开发人员遗忘的部分
- Denodo预测2023年数据管理和分析的未来
- 利用数据推动可持续发展
- 在 Vue3 中实现 React 原生 Hooks(useState、useEffect),深入理解 React Hooks 的