openwrt开发包含路由器基本功能的web问题记录

1.这里的扫描怎么实现的先找一些luci代码,在openwrt21版本后,luci用js替换了lua写后台,先找一些代码路径

在openrwt15这部分代码是在这个目录下

feeds/luci/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_join.htm

里面包含了html和lua,我们看一些lua部分是怎么实现的,直接copy代码

#!/usr/bin/lua

dev = arg[1]
local sys = require "luci.sys"
local utl = require "luci.util"
local iw = luci.sys.wifi.getiwinfo(dev)

    function scanlist(times)
        local i, k, v
        local l = { }
        local s = { }

        for i = 1, times do
            for k, v in ipairs(iw.scanlist or { }) do
                if not s[v.bssid] then
                    l[#l+1] = v
                    s[v.bssid] = true
                end
            end
        end

        return l
    end

    function format_wifi_encryption(info)
        if info.wep == true then
            return "WEP"
        elseif info.wpa > 0 then
            return string.format("Pairwise: %s / Group: %s >%s - %s",
                table.concat(info.pair_ciphers, ", "),
                table.concat(info.group_ciphers, ", "),
                (info.wpa == 3) and string.format("mixed WPA/WPA2")
                    or (info.wpa == 2 and "WPA2" or "WPA"),
                table.concat(info.auth_suites, ", ")
            )
        elseif info.enabled then
            return unknown
        else
            return open
        end
    end


for i, net in ipairs(scanlist(3)) do
    net.encryption = net.encryption or { }
    print("channel:",net.channel);
    print("ssid:",net.ssid);
    print("bssid:",net.bssid);
    print("Mode:",net.mode);
    wep=net.encryption.wep and 1 or 0
    
    print("Encryption:",format_wifi_encryption(net.encryption));
    print("");
end

使用方法:

root@OPENWRT:~# ./test.lua ra0

还有就是openwrt和Web服务器的交互,我们请求了Web服务器,它不是回josn格式或者什么xml格式数据,而是直接回给了我们html文件,我们可以通过抓包看到

这是我们的http get请求和得到下响应

把这个html直接用浏览器打开是这个样子,缺少了一些css这些样式的东西

openwrt21之后代码路径变为了如下:

feeds/luci/modules/luci-base/htdocs/luci-static/resources/network.js

feeds/luci/docs/jsapi/network.js.html

大概代码是这样子,看不懂,截取部分,用过调用ubus命令得到数据

	 */
	getMeshID: function() {
		if (this.getMode() != 'mesh')
			return null;

		return this.ubus('net', 'config', 'mesh_id') || this.get('mesh_id');
	},

	/**
	 * Get the configured BSSID of the wireless network.
	 *
	 * @returns {null|string}
	 * Returns the BSSID value or `null` if none has been specified.
	 */
	getBSSID: function() {
		return this.ubus('net', 'config', 'bssid') || this.get('bssid');
	},

类似这样:ubus call iwinfo info '{ "device": "wlan0" }'

2.虚拟机给路由器开发板传文件,确保虚拟机已安装ssh

scp  + 虚拟机里面要传的文件  + 开发板用户名@开发板ip地址:开发板放文件的路劲

 scp  mongoose root@192.168.1.1:/bin

3.路由器自己可以上网,下挂设备不能上网。

分别对比了路由表,fdb表,防火墙。发现路由器表,fdb表能上网和不能上网的时候,都是一样的,只有防火墙有差异。

fdb表

路由器表

防火墙

出问题的时候这样的

正常的情况是这样的

对比发现少了这一条,目前怀疑是这里导致的下挂设备不能上网。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值