返回博客列表
原 luci实现的wifidog认证服务
娱乐你我

  • 发布时间: 2014/12/26 11:05
  • 阅读: 4234
  • 收藏: 7
  • 点赞: 2
  • 评论: 1

利用luci写了个wifidog认证服务,实现直接openwrt路由器本地认证。直接安装ipk安装包,然后修改/etc/wifidog.conf文件(需要先安装wifidog),如下:

AuthServer {Hostname 192.168.1.1Path /cgi-bin/luci/wdas/MsgScriptPathFragment gw_message/?
}

主要的源码如下:

--[[
wdas -- wifidog auth server
mail: xzm2@qq.com
QQ: 529698939
]]--
module("luci.controller.wifidog.wdas", package.seeall)local session = require "luci.wifidogsession"
local http = luci.http
local translate = luci.i18n.translate
local wdcfg = require("luci.wifidogconfig")function index()local page    = node("wdas")page.target   = alias("wdas", "login")page.order    = 90page.i18n = "wifidogauth"page.setuser  = "nobody"page.setgroup = "nogroup"entry({"wdas", "login"}, call("login"))entry({"wdas", "logincheck"}, call("logincheck"))entry({"wdas", "auth"}, call("auth"))entry({"wdas", "ping"}, call("ping"))entry({"wdas", "portal"}, call("portal"))entry({"wdas", "gw_message"}, call("gw_message"))
endfunction login()--login/?gw_id=&gw_address=&gw_port=&mac=&url=luci.template.render("wifidog/wdas_login")
endfunction logincheck()local username, password = wdcfg.auth.username, wdcfg.auth.passwordlocal user, pwd, id, addr, port, mac, url, tokenuser = http.formvalue("user")pwd = http.formvalue("pwd")id = http.formvalue("gw_id")addr = http.formvalue("gw_address")port = http.formvalue("gw_port")mac = http.formvalue("mac")url = http.formvalue("url")token = http.getcookie("wdastok")http.prepare_content("application/json")if addr and port and mac and (user == username) and (pwd == password) thentoken = token and token:match("^[a-f0-9]*$") or luci.sys.uniqueid(16)local sdt = {id=id, addr=addr, port=port, mac=mac, url=url, timestamp=luci.sys.uptime()}local path = (http.getenv("SCRIPT_NAME") or "") .. "/wdas"session.write(token, sdt)http.header("Set-Cookie", "wdastok=" .. token .. "; path=" .. path)http.write('{url:"http://' .. addr .. ':' .. port ..'/wifidog/auth?token=' .. token .. '"}')elseif addr and port and mac thenhttp.write('{error: "' .. translate("Invalid username or password.") .. '"}')elsehttp.write('{error: "' .. translate("Invalid parameter.") .. '"}')endend
endfunction auth()--auth/?stage=&ip=&mac=&token=&incoming=&outgoing=local stage, ip, mac, token, incoming, outgoingstage = http.formvalue("stage")ip = http.formvalue("ip")mac = http.formvalue("mac")token = http.formvalue("token")incoming = http.formvalue("incoming")outgoing = http.formvalue("outgoing")token = token and token:match("^[a-f0-9]*$")local sdt = token and session.read(token)if token and sdt and (mac == sdt.mac) thenhttp.write("Auth: 1")elsehttp.write("Auth: 0")end
endfunction ping()--ping/?gw_id=&sys_load=&sys_memfree=&sys_load=&wifidog_uptime=local id, sys_uptime, sys_memfree, sys_load, wifidog_uptimeid = http.formvalue("gw_id")sys_uptime = http.formvalue("sys_uptime")sys_memfree = http.formvalue("sys_memfree")sys_load = http.formvalue("sys_load")wifidog_uptime = http.formvalue("wifidog_uptime")if id and sys_uptime and sys_memfree and sys_load and wifidog_uptime thenhttp.write("Pong")elsehttp.write("{error:2}")end
endfunction portal()--portal/?gw_id=%slocal token, sdt, urltoken = http.getcookie("wdastok")sdt = token and session.read(token)url = sdt and sdt.url or "http://www.baidu.com"http.redirect(url)
endfunction gw_message()local msg = http.formvalue("message")http.write(msg)
end

源码编译说明:

modules目录下的wifidogauth目录放到./feeds/luci/modules/下。

po/zh_CN/wifidogauth.po文件放到./feeds/luci/po/zh_CN/下。

./feeds/luci/contrib/package/luci/Makefile增加如下语句:

$(eval $(call module,wifidogauth,wifidog auth server,+luci-base))

然后 make menuconfig在luci-->Modules下找到luci-mod-wifidogauth选上。

make package/feeds/luci/luci/compile V=s

认证的用户名、密码的配置文件路径/etc/config/wifidogauth

效果图:

安装包下载地址:luci-mod-wifidogauth_0.12.ipk

完整源码下载地址:luci-mod-wifidogauth.tar.gz

luci实现的wifidog认证服务相关推荐

  1. wifidog java_GitHub - FangStarNet/wifidog-java-portal: 由 Java 实现的 WiFiDog 认证服务

    wifidog-java-portal 背景 在一些公共场所(比如公交车.地跌.机场等)连接当地的 WiFi 时会弹出一个验证表单,输入验证信息(比如短信验证码)后就能够通过该 WiFi 联网. Wi ...

  2. padavan搭建网页认证服务器,搭建 LNMP 的 Wifidog 网页认证服务 教程 感谢 elinpr0s 提供...

    提供的 wifidog 账号网页认证服务端 wifidog服务配置2016-8-7-1.png (30.73 KB, 下载次数: 7) 2016-8-7 23:58 上传 wifidog服务配置201 ...

  3. OpenWRT-Wifidog之利用Luci认证

    OpenWRT下实现Portal认证(WEB认证) 介绍了OpenWRT环境下实现Wifidog认证的办法,文末我曾经写道"有的人可能还会问,能不能把这些脚本集成到路由器当中,我的回答是能, ...

  4. wifi认证源码html,openwrt 实现本地wifidog简单认证,认证端纯html

    1 openwrt 安装 wifidog 2 在openwrt创建 /web 文件, 3 配置uhttpd 修改/etc/config/uhttpd文件 1,在最底部增加以下代码 config 'uh ...

  5. wifidog 配置文件

    下面回到路由器,编辑wifidog.conf,一般情况下,我们之后配置ExternalInterface,GatewayInterface和AuthServer这三项就可以,其他默认.下面是我的配置: ...

  6. 利用Wifidog实现微信wifi连接以及自写认证服务器

    前言 大家如果有用公共场合wifi的习惯,想必都有过如下的体验. 这就是利用微信身份来进行wifi连接认证,主要目的是商家为了吸引顾客,推广其公众号.别的也不多说,下面就来讲一讲怎么实现这样的wifi ...

  7. openwrt 认证收费_OpenWrt wifidog 实现收费提醒效果

    需求场景 有一个免认证的 Wifi SSID,比如叫:OpenWrt,附近的同学可以随便连上这个 SSID,没有缴过费的同学不管访问什么地址,都会被跳转到收费提醒页面,而缴过费的同学就可以开心上网了. ...

  8. 公共场所wifi认证解决方案wifidog+authpuppy

    服务器:linux mint 17.3 + authpuppy 路由器:DB120 + wifidog 手机一部 一.在OpenWrt的路由器上安装Wifidog应用程序 安装Wifidog程序有两种 ...

  9. pandorabox php,PandoraBox和openwrt下的wifidog安装及web认证界面设置

    前言: 1.因手头有一个7620A芯片的大功率无线路由器(智博通OEM的),由于要使用无线广告营销功能,但在网上搜寻了很久,都没找到合适的固件. 2.可能有人会说支持7620方案的广告营销固件多的是, ...

最新文章

  1. 香奈儿的 AI 实验室里,发生了什么?
  2. ArcGIS网络分析之构建网络分析数据集(一)
  3. Qt中 QString 和int,double等的转换
  4. IMX8QXP内部M4移植rt-thread
  5. Java中调用Oracle中的存储过程的单元测试代码
  6. 使用RSA算法解析令牌
  7. PAT1015 德才论(C++)
  8. 哈达玛变换的应用SATD、SAD等匹配算法
  9. html中表格table的内容居中显示
  10. Kubernetes Dashboard 终结者:KubeSphere
  11. android反编译apk命令,APK反编译关键命令及步骤
  12. 测试韩国真假唇釉软件,3ce蓝管唇釉怎么辨别真假 3ce唇釉推荐色号
  13. 网上能干啥副业?适合网上干的副业,副业兼职做什么好?
  14. 2020年笔记本电脑计算机专业,适合女生用的笔记本电脑排名2020
  15. win7 64系统,检测有没有装SP1补丁!
  16. python时间相减_python处理时间加减
  17. Centos7.4下安装Nvidia驱动
  18. js逆向案例-猿人学比赛题(中等及以下难度的)
  19. Linux之网络性能测试工具netperf实践
  20. 怎么压缩多张图片?如何快速批量压缩图片?

热门文章

  1. Android 重读官方文档 1
  2. 面向对象:让我们红尘作伴,吃的白白胖胖
  3. 人工智能 漆桂林_2020年CCF专委活动计划(预通过)
  4. python笔记2—day2
  5. K210入门必看(MAIX DOCK)(一)
  6. Linux I/O编程
  7. ADAMS中转动整个模型
  8. mmap内存映射原理
  9. 《利用Python进行数据分析》第七章——数据清洗与准备
  10. GTK构件 tree_view