mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-15 18:03:30 +00:00
add aprbind and luci
This commit is contained in:
parent
0e285c3037
commit
ab8216ce32
15
package/lean/luci-app-arpbind/Makefile
Executable file
15
package/lean/luci-app-arpbind/Makefile
Executable file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=ARP Binding
|
||||
LUCI_DEPENDS:=+ip-full
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
13
package/lean/luci-app-arpbind/luasrc/controller/arpbind.lua
Normal file
13
package/lean/luci-app-arpbind/luasrc/controller/arpbind.lua
Normal file
@ -0,0 +1,13 @@
|
||||
--[[
|
||||
静态ARP绑定 Luci页面 Controller
|
||||
Copyright (C) 2015 GuoGuo <gch981213@gmail.com>
|
||||
]]--
|
||||
|
||||
module("luci.controller.arpbind", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/arpbind") then
|
||||
return
|
||||
end
|
||||
entry({"admin", "network", "arpbind"}, cbi("arpbind"), _("IP/MAC Binding"), 45).dependent = true
|
||||
end
|
36
package/lean/luci-app-arpbind/luasrc/model/cbi/arpbind.lua
Normal file
36
package/lean/luci-app-arpbind/luasrc/model/cbi/arpbind.lua
Normal file
@ -0,0 +1,36 @@
|
||||
--[[
|
||||
静态ARP绑定 Luci页面 CBI page
|
||||
Copyright (C) 2015 GuoGuo <gch981213@gmail.com>
|
||||
]]--
|
||||
|
||||
local sys = require "luci.sys"
|
||||
local ifaces = sys.net:devices()
|
||||
|
||||
m = Map("arpbind", translate("IP/MAC Binding"),
|
||||
translatef("ARP is used to convert a network address (e.g. an IPv4 address) to a physical address such as a MAC address.Here you can add some static ARP binding rules."))
|
||||
|
||||
s = m:section(TypedSection, "arpbind", translate("Rules"))
|
||||
s.template = "cbi/tblsection"
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
|
||||
a = s:option(Value, "ipaddr", translate("IP Address"))
|
||||
a.datatype = "ipaddr"
|
||||
a.optional = false
|
||||
|
||||
a = s:option(Value, "macaddr", translate("MAC Address"))
|
||||
a.datatype = "macaddr"
|
||||
a.optional = false
|
||||
|
||||
a = s:option(ListValue, "ifname", translate("Interface"))
|
||||
for _, iface in ipairs(ifaces) do
|
||||
if iface ~= "lo" then
|
||||
a:value(iface)
|
||||
end
|
||||
end
|
||||
a.default = "br-lan"
|
||||
a.rmempty = false
|
||||
|
||||
return m
|
||||
|
||||
|
21
package/lean/luci-app-arpbind/po/zh-cn/arpbind.po
Normal file
21
package/lean/luci-app-arpbind/po/zh-cn/arpbind.po
Normal file
@ -0,0 +1,21 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Luci ARP Bind\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-06-23 20:16+0800\n"
|
||||
"PO-Revision-Date: 2015-06-23 20:17+0800\n"
|
||||
"Last-Translator: 981213 <gch981213@gmail.com>\n"
|
||||
"Language-Team: PandoraBox Team\n"
|
||||
"Language: zh_CN\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Poedit 1.8.1\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
|
||||
msgid "IP/MAC Binding"
|
||||
msgstr "IP/MAC绑定"
|
||||
|
||||
msgid "ARP is used to convert a network address (e.g. an IPv4 address) to a physical address such as a MAC address.Here you can add some static ARP binding rules."
|
||||
msgstr "ARP协议是用于实现网络地址到物理地址转换的协议。在这里,你可以设置静态ARP绑定规则。"
|
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
[ "$ACTION" = "ifup" ] && /etc/init.d/arpbind start
|
55
package/lean/luci-app-arpbind/root/etc/init.d/arpbind
Executable file
55
package/lean/luci-app-arpbind/root/etc/init.d/arpbind
Executable file
@ -0,0 +1,55 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# OpenWrt 静态ARP绑定 启动脚本
|
||||
# Copyright (C) 2015 GuoGuo <gch981213@gmail.com>
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/network.sh
|
||||
|
||||
#清除单接口ARP
|
||||
#参数:$1:接口名称
|
||||
if_clean_arp()
|
||||
{
|
||||
[ -z "$1" ] && return
|
||||
ip link set arp off dev $1
|
||||
ip link set arp on dev $1
|
||||
}
|
||||
|
||||
#清除系统所有ARP
|
||||
#参数:无
|
||||
clean_arp()
|
||||
{
|
||||
for i in $(ls /sys/class/net)
|
||||
do
|
||||
if_clean_arp $i
|
||||
done
|
||||
}
|
||||
|
||||
#添加静态ARP绑定
|
||||
#参数:$1:IP地址 $2:MAC地址 $3:接口名称
|
||||
add_arp()
|
||||
{
|
||||
[ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] && return
|
||||
echo "Adding ARP:IP Addr:$1 MAC Addr:$2 Interface:$3"
|
||||
ip neigh add $1 lladdr $2 nud permanent dev $3
|
||||
}
|
||||
|
||||
arpconf_foreach()
|
||||
{
|
||||
config_get ipaddr "$1" 'ipaddr'
|
||||
config_get macaddr "$1" 'macaddr'
|
||||
config_get ifname "$1" 'ifname'
|
||||
[ -z "$ifname" ] && return
|
||||
add_arp $ipaddr $macaddr $ifname
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
config_load 'arpbind'
|
||||
config_foreach arpconf_foreach 'arpbind'
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
clean_arp
|
||||
}
|
||||
|
12
package/lean/luci-app-arpbind/root/etc/uci-defaults/luci-arpbind
Executable file
12
package/lean/luci-app-arpbind/root/etc/uci-defaults/luci-arpbind
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
touch /etc/config/arpbind
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@arpbind[-1]
|
||||
add ucitrack arpbind
|
||||
set ucitrack.@arpbind[-1].init=arpbind
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user