mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-05 01:44:16 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,25 @@
|
||||
-- Copyright 2018-2019 Lienol <lawlienol@gmail.com>
|
||||
module("luci.controller.pppoe-server", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/pppoe-server") then return end
|
||||
|
||||
entry({"admin", "services", "pppoe-server"},
|
||||
alias("admin", "services", "pppoe-server", "settings"),
|
||||
_("PPPoE Server"), 3).acl_depends = { "luci-app-pppoe-server" }
|
||||
entry({"admin", "services", "pppoe-server", "settings"},
|
||||
cbi("pppoe-server/settings"), _("General Settings"), 10).leaf = true
|
||||
entry({"admin", "services", "pppoe-server", "users"},
|
||||
cbi("pppoe-server/users"), _("Users Manager"), 20).leaf = true
|
||||
entry({"admin", "services", "pppoe-server", "online"},
|
||||
cbi("pppoe-server/online"), _("Online Users"), 30).leaf = true
|
||||
entry({"admin", "services", "pppoe-server", "status"}, call("status")).leaf =
|
||||
true
|
||||
end
|
||||
|
||||
function status()
|
||||
local e = {}
|
||||
e.status = luci.sys.call("pidof %s >/dev/null" % "pppoe-server") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
local e = {}
|
||||
local o = require "luci.dispatcher"
|
||||
local a = luci.util.execi(
|
||||
"/bin/busybox top -bn1 | grep 'pppd plugin rp-pppoe.so' | grep -v 'grep'")
|
||||
for t in a do
|
||||
local a, n, h, s, o = t:match(
|
||||
"^ *(%d+) +(%d+) +.+rp_pppoe_sess 1:+([A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+[A-Fa-f0-9]) +.+options +(%S.-%S)%:(%S.-%S) ")
|
||||
local t = tonumber(a)
|
||||
if t then
|
||||
e["%02i.%s" % {t, "online"}] = {
|
||||
['PID'] = a,
|
||||
['PPID'] = n,
|
||||
['MAC'] = h,
|
||||
['GATEWAY'] = s,
|
||||
['CIP'] = o,
|
||||
['BLACKLIST'] = 0
|
||||
}
|
||||
end
|
||||
end
|
||||
f = SimpleForm("processes", translate("PPPoE Server"))
|
||||
f.reset = false
|
||||
f.submit = false
|
||||
f.description = translate(
|
||||
"The PPPoE server is a broadband access authentication server that prevents ARP spoofing.")
|
||||
t = f:section(Table, e, translate("Online Users"))
|
||||
t:option(DummyValue, "GATEWAY", translate("Server IP"))
|
||||
t:option(DummyValue, "CIP", translate("IP address"))
|
||||
t:option(DummyValue, "MAC", translate("MAC"))
|
||||
|
||||
kill = t:option(Button, "_kill", translate("Forced offline"))
|
||||
kill.inputstyle = "reset"
|
||||
function kill.write(e, t)
|
||||
null, e.tag_error[t] = luci.sys.process.signal(e.map:get(t, "PID"), 9)
|
||||
luci.http.redirect(o.build_url("admin/services/pppoe-server/online"))
|
||||
end
|
||||
return f
|
||||
@@ -0,0 +1,82 @@
|
||||
local s = require "luci.sys"
|
||||
local net = require"luci.model.network".init()
|
||||
local ifaces = s.net:devices()
|
||||
local m, s, o
|
||||
m = Map("pppoe-server", translate("PPPoE Server"))
|
||||
m.description = translate(
|
||||
"The PPPoE server is a broadband access authentication server that prevents ARP spoofing.")
|
||||
m.template = "pppoe-server/index"
|
||||
s = m:section(TypedSection, "service")
|
||||
s.anonymous = true
|
||||
o = s:option(DummyValue, "rp_pppoe_server_status",
|
||||
translate("Current Condition"))
|
||||
o.template = "pppoe-server/status"
|
||||
o.value = translate("Collecting data...")
|
||||
o = s:option(Flag, "enabled", translate("Enable"),
|
||||
translate("Enable or disable the PPPoE server"))
|
||||
o.rmempty = false
|
||||
o = s:option(ListValue, "client_interface", translate("Client Interface"),
|
||||
translate("Listen in this interface"))
|
||||
for _, iface in ipairs(ifaces) do
|
||||
if (iface:match("^br") or iface:match("^eth*") or iface:match("^pppoe*") or iface:match("wlan*")) 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(Value, "localip", translate("Server IP"),
|
||||
translate("PPPoE Server IP address.default: 10.0.1.1"))
|
||||
o.datatype = "ipaddr"
|
||||
o.placeholder = translate("10.0.1.1")
|
||||
o.rmempty = true
|
||||
o.default = "10.0.1.1"
|
||||
o = s:option(Value, "remoteip", translate("Client IP"),
|
||||
translate("PPPoE Client IP address.default: 10.0.1.100-254"))
|
||||
o.placeholder = translate("10.0.1.100-254")
|
||||
o.rmempty = true
|
||||
o.default = "10.0.1.100-254"
|
||||
o = s:option(Value, "count", translate("Client upper limit"), translate(
|
||||
"Specify how many clients can connect to the server simultaneously."))
|
||||
o.placeholder = translate("50")
|
||||
o.rmempty = true
|
||||
o.default = "50"
|
||||
o = s:option(Value, "dns1", translate("DNS IP address1"), translate(
|
||||
"Set the PPPoE server to default DNS server, which is not required."))
|
||||
o.placeholder = translate("10.0.1.1")
|
||||
o.datatype = "ipaddr"
|
||||
o.default = "10.0.1.1"
|
||||
o = s:option(Value, "dns2", translate("DNS IP address2"), translate(
|
||||
"Set the PPPoE server to default DNS server, which is not required."))
|
||||
o.placeholder = translate("119.29.29.29")
|
||||
o.datatype = "ipaddr"
|
||||
o.default = "119.29.29.29"
|
||||
o = s:option(Value, "mru", translate("mru"), translate(
|
||||
"You may not be able to access the Internet if you don't set it up properly.default: 1492"))
|
||||
o.default = "1492"
|
||||
o = s:option(Value, "mtu", translate("mtu"), translate(
|
||||
"You may not be able to access the Internet if you don't set it up properly.default: 1492"))
|
||||
o.default = "1492"
|
||||
o = s:option(Flag, "is_nat", translate("is_nat"))
|
||||
o.rmempty = false
|
||||
o = s:option(ListValue, "export_interface", translate("Interface"),
|
||||
translate("Specify interface forwarding traffic."))
|
||||
o:value("default", translate("default"))
|
||||
for _, iface in ipairs(ifaces) do
|
||||
if (iface:match("^br") or iface:match("^eth*") or iface:match("^pppoe*") or iface:match("wlan*")) 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:depends("is_nat", "1")
|
||||
o = s:option(Value, "log", translate("Log"),
|
||||
translate("Log save path, default: /var/log/pppoe-server.log"))
|
||||
o.default = "/var/log/pppoe-server.log"
|
||||
o.rmempty = false
|
||||
return m
|
||||
@@ -0,0 +1,28 @@
|
||||
m = Map("pppoe-server", translate("PPPoE Server"))
|
||||
m.description = translate(
|
||||
"The PPPoE server is a broadband access authentication server that prevents ARP spoofing.")
|
||||
s = m:section(TypedSection, "user", translate("Users Manager"))
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
s.template = "cbi/tblsection"
|
||||
|
||||
o = s:option(Flag, "enabled", translate("Enabled"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "username", translate("User name"))
|
||||
o.placeholder = translate("User name")
|
||||
o.rmempty = true
|
||||
|
||||
o = s:option(Value, "password", translate("Password"))
|
||||
o.rmempty = true
|
||||
|
||||
o = s:option(Value, "ipaddress", translate("IP address"))
|
||||
o.placeholder = translate("Automatically")
|
||||
o.datatype = "ipaddr"
|
||||
o.rmempty = true
|
||||
function o.cfgvalue(e, t)
|
||||
value = e.map:get(t, "ipaddress")
|
||||
return value == "*" and "" or value
|
||||
end
|
||||
function o.remove(e, t) Value.write(e, t, "*") end
|
||||
return m
|
||||
@@ -0,0 +1,13 @@
|
||||
<% include("cbi/map") %>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "services", "pppoe-server", "status")%>', null,
|
||||
function(x, result)
|
||||
{
|
||||
var status = document.getElementsByClassName('pppoe_server_status')[0];
|
||||
status.setAttribute("style","font-weight:bold;");
|
||||
status.setAttribute("color",result.status ? "green":"red");
|
||||
status.innerHTML = result.status?'<%=translate("RUNNING")%>':'<%=translate("NOT RUNNING")%>';
|
||||
}
|
||||
)
|
||||
//]]>
|
||||
</script>
|
||||
@@ -0,0 +1,3 @@
|
||||
<%+cbi/valueheader%>
|
||||
<font class="pppoe_server_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
|
||||
<%+cbi/valuefooter%>
|
||||
Reference in new issue
Block a user