mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
add luci app pppoe relay
This commit is contained in:
parent
2614b0bfcf
commit
b844ac9918
18
package/lean/luci-app-pppoe-relay/Makefile
Normal file
18
package/lean/luci-app-pppoe-relay/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for PPPoE Relay
|
||||
LUCI_DEPENDS:=+rp-pppoe-common +rp-pppoe-relay
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
module("luci.controller.pppoe-relay",package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/pppoe-relay")then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin","services","pppoe-relay"},cbi("pppoe-relay"),_("PPPoE Relay"),90).dependent=true
|
||||
|
||||
end
|
@ -0,0 +1,56 @@
|
||||
local s=require"luci.sys"
|
||||
local net = require "luci.model.network".init()
|
||||
local ifaces = s.net:devices()
|
||||
local m,s,o
|
||||
|
||||
m=Map("pppoe-relay",translate("PPPoE Relay"))
|
||||
m.description = translate("Opening the PPPoE relay allows devices in the Intranet to create a separate PPPoE connection that can cross NAT.")
|
||||
s=m:section(TypedSection,"service")
|
||||
s.addremove=true
|
||||
s.anonymous=true
|
||||
s.template="cbi/tblsection"
|
||||
|
||||
o=s:option(Flag,"enabled",translate("Enabled"))
|
||||
o.rmempty=false
|
||||
|
||||
o=s:option(ListValue,"server_interface",translate("Server Interface"))
|
||||
for _, iface in ipairs(ifaces) do
|
||||
if not (iface == "lo" or iface:match("^ifb.*") or iface:match("gre*")) then
|
||||
local nets = net:get_interface(iface)
|
||||
nets = nets and nets:get_networks() or {}
|
||||
for k, v in pairs(nets) do
|
||||
nets[k] = nets[k].sid
|
||||
end
|
||||
nets = table.concat(nets, ",")
|
||||
o:value(iface, ((#nets > 0) and "%s (%s)" % {iface, nets} or iface))
|
||||
end
|
||||
end
|
||||
o.rmempty=true
|
||||
|
||||
o=s:option(ListValue,"client_interface",translate("Client Interface"))
|
||||
for _, iface in ipairs(ifaces) do
|
||||
if not (iface == "lo" or iface:match("^ifb.*") or iface:match("gre*")) then
|
||||
local nets = net:get_interface(iface)
|
||||
nets = nets and nets:get_networks() or {}
|
||||
for k, v in pairs(nets) do
|
||||
nets[k] = nets[k].sid
|
||||
end
|
||||
nets = table.concat(nets, ",")
|
||||
o:value(iface, ((#nets > 0) and "%s (%s)" % {iface, nets} or iface))
|
||||
end
|
||||
end
|
||||
o.rmempty=true
|
||||
|
||||
o=s:option(Button,"is_run",translate("Check"))
|
||||
function o.write(self, section)
|
||||
local server_interface = m.uci:get('pppoe-relay',section,"server_interface")
|
||||
local client_interface = m.uci:get('pppoe-relay',section,"client_interface")
|
||||
isrun=luci.sys.call("ps | grep '/usr/sbin/pppoe-relay -S "..server_interface.." -C "..client_interface.."' | grep -v 'grep' >/dev/null")
|
||||
if isrun == 1 then
|
||||
o.description = "<script>alert('"..translate("NOT RUNNING").."');</script>"
|
||||
else
|
||||
o.description = "<script>alert('"..translate("RUNNING").."');</script>"
|
||||
end
|
||||
end
|
||||
|
||||
return m
|
23
package/lean/luci-app-pppoe-relay/po/zh-cn/pppoe-relay.po
Normal file
23
package/lean/luci-app-pppoe-relay/po/zh-cn/pppoe-relay.po
Normal file
@ -0,0 +1,23 @@
|
||||
msgid "PPPoE Relay"
|
||||
msgstr "PPPoE 穿透"
|
||||
|
||||
msgid "Opening the PPPoE relay allows devices in the Intranet to create a separate PPPoE connection that can cross NAT."
|
||||
msgstr "开启 PPPoE 中继允许内网中的设备创建一个可穿过 NAT 的独立 PPPoE 连接"
|
||||
|
||||
msgid "Enable or disable the PPPoE Relay"
|
||||
msgstr "启用或禁用PPPoE穿透"
|
||||
|
||||
msgid "Server Interface"
|
||||
msgstr "服务端接口"
|
||||
|
||||
msgid "Specify the PPPoE server interface"
|
||||
msgstr "指定PPPoE服务器接口"
|
||||
|
||||
msgid "Client Interface"
|
||||
msgstr "客户端接口"
|
||||
|
||||
msgid "Specify the PPPoE client interface"
|
||||
msgstr "指定PPPoE客户端接口"
|
||||
|
||||
msgid "Enabled"
|
||||
msgstr "启用"
|
@ -0,0 +1 @@
|
||||
|
29
package/lean/luci-app-pppoe-relay/root/etc/init.d/pppoe-relay
Executable file
29
package/lean/luci-app-pppoe-relay/root/etc/init.d/pppoe-relay
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2018 Lienol <lienol@qq.com>
|
||||
|
||||
START=99
|
||||
STOP=16
|
||||
|
||||
setup_service() {
|
||||
local section="$1"
|
||||
config_get enabled "$section" enabled
|
||||
[ "$enabled" -eq 0 ] && return 0
|
||||
config_get server_interface "$section" server_interface
|
||||
config_get client_interface "$section" client_interface
|
||||
[ -n "$server_interface" ] || return 0
|
||||
[ -n "$client_interface" ] || return 0
|
||||
|
||||
is_run=$(ps | grep "/usr/sbin/pppoe-relay -S $server_interface -C $client_interface" | grep -v "grep")
|
||||
[ -z "$is_run" ] && {
|
||||
/usr/sbin/pppoe-relay -S $server_interface -C $client_interface
|
||||
}
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load pppoe-relay
|
||||
config_foreach setup_service service
|
||||
}
|
||||
|
||||
stop() {
|
||||
killall -9 pppoe-relay
|
||||
}
|
11
package/lean/luci-app-pppoe-relay/root/etc/uci-defaults/luci-app-pppoe-relay
Executable file
11
package/lean/luci-app-pppoe-relay/root/etc/uci-defaults/luci-app-pppoe-relay
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@pppoe-relay[-1]
|
||||
add ucitrack pppoe-relay
|
||||
set ucitrack.@pppoe-relay[-1].init=pppoe-relay
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user