mirror of
https://github.com/sirpdboy/sirpdboy-package.git
synced 2025-01-07 03:17:03 +08:00
add luci-app-easymesh
This commit is contained in:
parent
297c31460c
commit
506cd49146
13
luci-app-easymesh/Makefile
Normal file
13
luci-app-easymesh/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
#-- Copyright (C) 2021 dz <dingzhong110@gmail.com>
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI Support for easymesh
|
||||
LUCI_DEPENDS:= +batctl-full +kmod-batman-adv +wpad-openssl
|
||||
PKG_VERSION:=1.1
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
2
luci-app-easymesh/README.md
Normal file
2
luci-app-easymesh/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# luci-app-easymesh
|
||||
水平有限写了基于kmod-batman-adv+802.11s 有线+无线回程的mesh luci设置插件。写的很烂暂时能用
|
14
luci-app-easymesh/luasrc/controller/easymesh.lua
Normal file
14
luci-app-easymesh/luasrc/controller/easymesh.lua
Normal file
@ -0,0 +1,14 @@
|
||||
#-- Copyright (C) 2021 dz <dingzhong110@gmail.com>
|
||||
|
||||
module("luci.controller.easymesh", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/easymesh") then
|
||||
return
|
||||
end
|
||||
|
||||
local page
|
||||
|
||||
page = entry({"admin", "network", "easymesh"}, cbi("easymesh"), _("EASY MESH"), 60)
|
||||
page.dependent = true
|
||||
end
|
67
luci-app-easymesh/luasrc/model/cbi/easymesh.lua
Normal file
67
luci-app-easymesh/luasrc/model/cbi/easymesh.lua
Normal file
@ -0,0 +1,67 @@
|
||||
-- Copyright (C) 2021 dz <dingzhong110@gmail.com>
|
||||
|
||||
local m,s,o
|
||||
local SYS = require "luci.sys"
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local ipc = require "luci.ip"
|
||||
local net = require "luci.model.network".init()
|
||||
local sys = require "luci.sys"
|
||||
local ifaces = sys.net:devices()
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
|
||||
-- Basic
|
||||
m = Map("easymesh")
|
||||
s = m:section(TypedSection, "easymesh", translate("Settings"), translate("General Settings"))
|
||||
s.anonymous = true
|
||||
|
||||
---- Eanble
|
||||
o = s:option(Flag, "enabled", translate("Enable"), translate("Enable or disable EASY MESH"))
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "interface", translate("interface"), translate(""))
|
||||
o:value("radio0", "radio0")
|
||||
o:value("radio1", "radio1")
|
||||
o:value("radio2", "radio2")
|
||||
o.default = "radio0"
|
||||
o.rmempty = false
|
||||
|
||||
---- mesh
|
||||
o = s:option(Value, "mesh_id", translate("MESH ID"))
|
||||
o.default = "easymesh"
|
||||
o.description = translate("MESH ID")
|
||||
|
||||
enable = s:option(Flag, "encryption", translate("Encryption"), translate(""))
|
||||
enable.default = 0
|
||||
enable.rmempty = false
|
||||
|
||||
o = s:option(Value, "key", translate("Key"))
|
||||
o.default = "easymesh"
|
||||
o:depends("encryption", 1)
|
||||
|
||||
---- ap_mode
|
||||
enable = s:option(Flag, "ap_mode", translate("AP MODE Enable"), translate("Enable or disable AP MODE"))
|
||||
enable.default = 0
|
||||
enable.rmempty = false
|
||||
|
||||
o = s:option(Value, "ipaddr", translate("IPv4-Address"))
|
||||
o.default = "192.168.1.10"
|
||||
o.datatype = "ip4addr"
|
||||
o:depends("ap_mode", 1)
|
||||
|
||||
o = s:option(Value, "netmask", translate("IPv4 netmask"))
|
||||
o.default = "255.255.255.0"
|
||||
o.datatype = "ip4addr"
|
||||
o:depends("ap_mode", 1)
|
||||
|
||||
o = s:option(Value, "gateway", translate("IPv4 gateway"))
|
||||
o.default = "192.168.1.1"
|
||||
o.datatype = "ip4addr"
|
||||
o:depends("ap_mode", 1)
|
||||
|
||||
o = s:option(Value, "dns", translate("Use custom DNS servers"))
|
||||
o.default = "192.168.1.1"
|
||||
o.datatype = "ip4addr"
|
||||
o:depends("ap_mode", 1)
|
||||
|
||||
return m
|
47
luci-app-easymesh/po/zh-cn/easymesh.po
Normal file
47
luci-app-easymesh/po/zh-cn/easymesh.po
Normal file
@ -0,0 +1,47 @@
|
||||
msgid "easymesh"
|
||||
msgstr "easymesh"
|
||||
|
||||
msgid "EASY MESH"
|
||||
msgstr "简单MESH"
|
||||
|
||||
msgid "Settings"
|
||||
msgstr "设置"
|
||||
|
||||
msgid "General Settings"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "interface"
|
||||
msgstr "接口"
|
||||
|
||||
msgid "AUTO"
|
||||
msgstr "自动"
|
||||
|
||||
msgid "Enable or disable EASY MESH"
|
||||
msgstr "启用或禁用简单MESH"
|
||||
|
||||
msgid "Encryption"
|
||||
msgstr "加密"
|
||||
|
||||
msgid "Key"
|
||||
msgstr "密码"
|
||||
|
||||
msgid "AP MODE Enable"
|
||||
msgstr "启用AP模式"
|
||||
|
||||
msgid "Enable or disable AP MODE"
|
||||
msgstr "启用或禁用AP模式"
|
||||
|
||||
msgid "IPv4-Address"
|
||||
msgstr "IPv4 地址"
|
||||
|
||||
msgid "IPv4 netmask"
|
||||
msgstr "IPv4 子网掩码"
|
||||
|
||||
msgid "IPv4 gateway"
|
||||
msgstr "IPv4 网关"
|
||||
|
||||
msgid "Use custom DNS servers"
|
||||
msgstr "使用自定义的 DNS 服务器"
|
8
luci-app-easymesh/root/etc/config/easymesh
Normal file
8
luci-app-easymesh/root/etc/config/easymesh
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
config easymesh 'config'
|
||||
option enabled '0'
|
||||
option ap_mode '0'
|
||||
option ipaddr '192.168.1.10'
|
||||
option netmask '255.255.255.0'
|
||||
option gateway '192.168.1.1'
|
||||
option dns '192.168.1.1'
|
152
luci-app-easymesh/root/etc/init.d/easymesh
Normal file
152
luci-app-easymesh/root/etc/init.d/easymesh
Normal file
@ -0,0 +1,152 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=99
|
||||
STOP=30
|
||||
|
||||
enable=$(uci get easymesh.config.enabled 2>/dev/null)
|
||||
mesh_bat0=$(uci get network.bat0 2>/dev/null)
|
||||
mesh_nwi_mesh0=$(uci get network.nwi_mesh0 2>/dev/null)
|
||||
mesh_mesh0=$(uci get wireless.mesh0 2>/dev/null)
|
||||
ap_mode=$(uci get easymesh.config.ap_mode 2>/dev/null)
|
||||
lan=$(uci get network.lan.ifname 2>/dev/null)
|
||||
ipaddr=$(uci get easymesh.config.ipaddr 2>/dev/null)
|
||||
netmask=$(uci get easymesh.config.netmask 2>/dev/null)
|
||||
gateway=$(uci get easymesh.config.gateway 2>/dev/null)
|
||||
#ap_gateway=$(uci get network.lan.gateway 2>/dev/null)
|
||||
dns=$(uci get easymesh.config.dns 2>/dev/null)
|
||||
mesh_id=$(uci get easymesh.config.mesh_id 2>/dev/null)
|
||||
interface=$(uci get easymesh.config.interface 2>/dev/null)
|
||||
mesh0_interface=$(uci get wireless.mesh0.device 2>/dev/null)
|
||||
encryption=$(uci get easymesh.config.encryption 2>/dev/null)
|
||||
key=$(uci get easymesh.config.key 2>/dev/null)
|
||||
|
||||
start(){
|
||||
if [ $enable -eq 1 ]; then
|
||||
if [ x$mesh_bat0 != x"interface" ]; then
|
||||
uci set network.bat0=interface
|
||||
uci set network.bat0.proto='batadv'
|
||||
uci set network.bat0.routing_algo='BATMAN_IV'
|
||||
uci set network.bat0.aggregated_ogms='1'
|
||||
#uci set network.bat0.gw_bandwidth='10000/2000'
|
||||
uci set network.bat0.ap_isolation='0'
|
||||
uci set network.bat0.bonding='0'
|
||||
uci set network.bat0.fragmentation='1'
|
||||
uci set network.bat0.gw_mode='off'
|
||||
#uci set network.bat0.gw_sel_class='20'
|
||||
uci set network.bat0.log_level='0'
|
||||
uci set network.bat0.orig_interval='1000'
|
||||
uci set network.bat0.bridge_loop_avoidance='1'
|
||||
uci set network.bat0.distributed_arp_table='1'
|
||||
uci set network.bat0.multicast_mode='1'
|
||||
uci set network.bat0.network_coding='0'
|
||||
uci set network.bat0.hop_penalty='30'
|
||||
uci set network.bat0.isolation_mark='0x00000000/0x00000000'
|
||||
|
||||
uci add_list network.lan.ifname='bat0'
|
||||
uci commit network
|
||||
fi
|
||||
|
||||
if [ x$mesh_nwi_mesh0 != x"interface" ]; then
|
||||
uci set network.nwi_mesh0=interface
|
||||
uci set network.nwi_mesh0.proto='batadv_hardif'
|
||||
uci set network.nwi_mesh0.mtu='2304'
|
||||
uci set network.nwi_mesh0.master='bat0'
|
||||
uci commit network
|
||||
fi
|
||||
|
||||
if [ x$mesh_mesh0 != x"wifi-iface" ]; then
|
||||
uci set wireless.mesh0=wifi-iface
|
||||
uci set wireless.mesh0.device=$interface
|
||||
uci set wireless.mesh0.ifname='mesh0'
|
||||
uci set wireless.mesh0.network='nwi_mesh0'
|
||||
uci set wireless.mesh0.mode='mesh'
|
||||
uci set wireless.mesh0.mesh_fwding='0'
|
||||
uci set wireless.mesh0.mesh_id=$mesh_id
|
||||
uci commit wireless
|
||||
fi
|
||||
if [ x$mesh_mesh0 = x"wifi-iface" ]; then
|
||||
if [ x$mesh0_interface != x$interface ]; then
|
||||
uci set wireless.mesh0.device=$interface
|
||||
uci commit wireless
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $encryption -ne 1 ]; then
|
||||
uci set wireless.mesh0.encryption='none'
|
||||
uci commit wireless
|
||||
else
|
||||
uci set wireless.mesh0.encryption='sae'
|
||||
uci set wireless.mesh0.key=$key
|
||||
uci commit wireless
|
||||
fi
|
||||
|
||||
if [ $ap_mode -eq 1 ]; then
|
||||
uci set network.lan.ipaddr=$ipaddr
|
||||
uci set network.lan.netmask=$netmask
|
||||
uci set network.lan.gateway=$gateway
|
||||
uci set network.lan.dns=$dns
|
||||
uci commit network
|
||||
|
||||
uci set dhcp.lan.dynamicdhcp='0'
|
||||
uci delete dhcp.lan.ra
|
||||
uci delete dhcp.lan.dhcpv6
|
||||
uci delete dhcp.lan.ra_management
|
||||
uci commit dhcp
|
||||
|
||||
/etc/init.d/odhcpd stop && /etc/init.d/odhcpd disable
|
||||
/etc/init.d/firewall stop && /etc/init.d/firewall disable
|
||||
/etc/init.d/network restart
|
||||
else
|
||||
uci delete network.lan.gateway
|
||||
uci delete network.lan.dns
|
||||
uci commit network
|
||||
|
||||
uci delete dhcp.lan.dynamicdhcp
|
||||
uci commit dhcp
|
||||
|
||||
/etc/init.d/odhcpd enable && /etc/init.d/odhcpd start
|
||||
/etc/init.d/firewall enable && /etc/init.d/firewall start
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
#batctl add if mesh0
|
||||
#brctl addif br-lan bat0
|
||||
#ifconfig bat0 up
|
||||
fi
|
||||
}
|
||||
|
||||
stop(){
|
||||
if [ $enable -ne 1 ]; then
|
||||
if [ x$mesh_bat0 = x"interface" ]; then
|
||||
uci delete network.bat0
|
||||
uci del_list network.lan.ifname='bat0'
|
||||
uci commit network
|
||||
fi
|
||||
|
||||
if [ x$mesh_nwi_mesh0 = x"interface" ]; then
|
||||
uci delete network.nwi_mesh0
|
||||
uci commit network
|
||||
fi
|
||||
|
||||
if [ x$mesh_mesh0 = x"wifi-iface" ]; then
|
||||
uci delete wireless.mesh0
|
||||
uci commit wireless
|
||||
fi
|
||||
|
||||
if [ $ap_mode -ne 1 ]; then
|
||||
uci delete network.lan.gateway
|
||||
uci delete network.lan.dns
|
||||
uci commit network
|
||||
|
||||
uci delete dhcp.lan.dynamicdhcp
|
||||
uci commit dhcp
|
||||
|
||||
/etc/init.d/odhcpd enable && /etc/init.d/odhcpd start
|
||||
/etc/init.d/firewall enable && /etc/init.d/firewall start
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
11
luci-app-easymesh/root/etc/uci-defaults/luci-easymesh
Normal file
11
luci-app-easymesh/root/etc/uci-defaults/luci-easymesh
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@easymesh[-1]
|
||||
add ucitrack easymesh
|
||||
set ucitrack.@easymesh[-1].init=easymesh
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user