分类 wifidog安装 下的文章

Wifidog鉴权服务器wifidog-auth的搭建

原来已经配置好的apache2、python、trac系统
在/etc/apache2/sites-enabled下增加的新的配置文件(域名和对应的目录)

sudo /etc/init.d/apache2 restart

这是可以用新域名访问对应目录下index.php了,但无法执行php代码只能下载该文件

sudo apt-get install php5
sudo apt-get install libapache2-mod-php5 # 安装遇到麻烦
sudo apt-get install postgresql
sudo apt-get install php5-cgi php5-common php5-pgsql php-pear php5-xmlrpc php5-curl language-pack-en-base subversion
sudo pear install XML_RPC
wget http://sourceforge.net/projects/phlickr/files/Phlickr-0.2.5.tgz
sudo pear install Phlickr-0.2.5.tgz
sudo apt-get install openssh-server
sudo apt-get install postfix
选择"internet site with smart host",然后配置

svn checkout https:// dev.wifidog.org/svn/trunk/wifidog-auth #放到/var/www目录下

现在修改文件/var/www/wifidog-auth/wifidog/classes/Dependency.php,否则智能安装会失败
$sudo vim /var/www/wifidog-auth/wifidog/classes/Dependency.php
将第122行改为:'website' => "http://www.smarty.net/" 
将第123行改为:'installSourceUrl' => http://www.smarty.net/files/Smarty-2.6.26.tar.gz

$sudo vim /var/www/wifidog-auth/wifidog/config.php
将define('DEFAULT_LANG', 'fr_CA');改为define('DEFAULT_LANG', 'en_US');

本文章由 http://www.wifidog.pro/2015/02/06/wifidog-auth.html 整理编辑,转载请注明出处

DDWRT wifidog配置

设置步骤
将无线路由器接入Internet。
设置好无线配置等。

点击“服务”->“热点”标签页(参考下图)。
1.jpg

按照以下配置各项目(参考下图):

Wifidog守护进程: 选择“启用”
网关ID: 填写Web控制面板中创建的热点的Hotspot ID
Web服务器名: 填写“Wiwiz”
端口: 使用默认值
最大用户数: 使用默认值,或可按实际需要填写
检查间隔 (秒) : 使用默认值
客户端超时: 使用默认值
鉴权服务器主机名: 填写“cp.wiwiz.com”
鉴权服务器SSL启用: 选择“禁用”
鉴权服务器HTTP端口: 使用默认值
鉴权服务器路径: 填写“/as/s/”

2.jpg

然后,点击“应用”按钮。
最后,你可以使用一个Wi-Fi客户端(如带WLAN适配器的PC或者支持Wi-Fi的移动电话)测试一下你的热点:

  • 搜索可用Wi-Fi热点,并连接到你的热点。
  • 打开Web浏览器,输入任何一个HTTP开头的网址。如果你的热点的认证页面能够显示出来,就说明你的热点已经正常运转了。

本文章由 http://www.wifidog.pro/2015/02/05/ddwrt-wifidog-1.html 整理编辑,转载请注明出处

OpenWrt WiFiDog进程简单描述其程序架构

最近网络营销路由器很火,在智能路由器的烘托下,广告路由器也在如火如荼的展开,不少公司都在向这块进发。

WiFiDog 进程的核心是iptables的规则路由,如若想深入了解其运行步骤需要对iptables有个基础的认识Chain, 三个表五条链。

除了iptables之外,还有一个处理认证前的HTTP请求的web服务器,默认端口为2060。

还有一些线程完成定期汇报,检查状态等。

认证服务器需要自己搭建。

线程:
1)ping 保活协议
2)定时检查客户端是否超时
3)HTTP 请求处理
4)一个不经常用的线程:wifidog 控制线程

本文章由http://www.wifidog.pro/2015/02/05/wifidog%E6%A1%86%E6%9E%B6.html整理编辑,转载请注明出处

luci实现的wifidog认证服务

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

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

主要的源码如下:

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    = 90
    page.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"))
end

function login()
    --login/?gw_id=&gw_address=&gw_port=&mac=&url=
    luci.template.render("wifidog/wdas_login")
end

function logincheck()
    local username, password = wdcfg.auth.username, wdcfg.auth.password
    local user, pwd, id, addr, port, mac, url, token
    user = 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) then
        token = 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 .. '"}')
    else
        if addr and port and mac then
            http.write('{error: "' .. translate("Invalid username or password.") .. '"}')
        else
            http.write('{error: "' .. translate("Invalid parameter.") .. '"}')
        end
    end
end

function auth()
    --auth/?stage=&ip=&mac=&token=&incoming=&outgoing=
    local stage, ip, mac, token, incoming, outgoing
    stage = 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) then
        http.write("Auth: 1")
    else
        http.write("Auth: 0")
    end
end

function ping()
    --ping/?gw_id=&sys_load=&sys_memfree=&sys_load=&wifidog_uptime=
    local id, sys_uptime, sys_memfree, sys_load, wifidog_uptime
    id = 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 then
        http.write("Pong")
    else
        http.write("{error:2}")
    end
end

function portal()
    --portal/?gw_id=%s
    local token, sdt, url
    token = http.getcookie("wdastok")
    sdt = token and session.read(token)
    url = sdt and sdt.url or "http://www.baidu.com"
    http.redirect(url)
end

function 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

本文章由 http://www.wifidog.pro/2015/02/05/luci-wifidog.html 整理编辑,转载请注明出处