🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
# Copyright (C) 2018-2020 Lienol <lawlienol@gmail.com>
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for PPPoE Server
LUCI_DEPENDS:=+luci-compat +rp-pppoe-common +rp-pppoe-server
PKG_VERSION:=20200326
PKG_RELEASE:=1
define Package/luci-app-pppoe-server/preinst
#!/bin/sh
rm -rf $${IPKG_INSTROOT}/etc/config/pppoe-server >/dev/null 2>&1
rm -rf $${IPKG_INSTROOT}/etc/init.d/pppoe-server >/dev/null 2>&1
exit 0
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -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%>
+1
View File
@@ -0,0 +1 @@
zh_Hans
@@ -0,0 +1,101 @@
msgid "PPPoE Server"
msgstr "PPPoE 服务器"
msgid "The PPPoE server is a broadband access authentication server that prevents ARP spoofing."
msgstr "PPPoE服务器是一个宽带接入认证服务器,可以防止ARP欺骗."
msgid "PPPoE Server status"
msgstr "PPPoE 服务器运行状态"
msgid "Current Condition"
msgstr "当前状态"
msgid "General settings"
msgstr "基本设置"
msgid "Enable or disable the PPPoE server"
msgstr "启用或禁用PPPoE服务器"
msgid "Client Interface"
msgstr "客户端接口"
msgid "Listen in this interface"
msgstr "监听客户端接口"
msgid "Server IP"
msgstr "服务器 IP 地址"
msgid "PPPoE Server IP address.default: 10.0.1.1"
msgstr "PPPoE 服务器远程地址。默认:10.0.1.1"
msgid "Client IP"
msgstr "客户端 IP 地址"
msgid "PPPoE Client IP address.default: 10.0.1.100-254"
msgstr "分配给客户端的 IP 地址范围。默认:10.0.1.100-254"
msgid "DNS IP address1"
msgstr "DNS 1"
msgid "DNS IP address2"
msgstr "DNS 2"
msgid "Set the PPPoE server to default DNS server, which is not required."
msgstr "设置 PPPoE 服务器第一个 DNS 服务器,该设置非必须。"
msgid "Set the PPPoE server to default DNS server, which is not required."
msgstr "设置 PPPoE 服务器第二个 DNS 服务器,该设置非必须。"
msgid "Client upper limit"
msgstr "客户端上限数"
msgid "Specify how many clients can connect to the server simultaneously."
msgstr "指定有多少客户端可以同时连接到服务器"
msgid "You may not be able to access the Internet if you don't set it up properly.default: 1492"
msgstr "如果设置不当,你可能无法访问互联网。默认:1492"
msgid "is_nat"
msgstr "NAT转发"
msgid "Interface"
msgstr "接口"
msgid "Specify interface forwarding traffic."
msgstr "指定接口转发流量。"
msgid "Log"
msgstr "日志"
msgid "Log save path, default: /var/log/pppoe-server.log"
msgstr "日志保存路径,默认:/var/log/pppoe-server.log"
msgid "Users Manager"
msgstr "用户管理"
msgid "Enabled"
msgstr "启用"
msgid "User name"
msgstr "用户名"
msgid "Password"
msgstr "密码"
msgid "IP address"
msgstr "IP 地址"
msgid "Automatically"
msgstr "自动分配"
msgid "Online Users""
msgstr "在线用户"
msgid "Forced offline"
msgstr "强制下线"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "RUNNING"
msgstr "运行中"
@@ -0,0 +1,21 @@
config service
option localip '10.0.1.1'
option log '/var/log/pppoe-server.log'
option count '50'
option mru '1492'
option mtu '1492'
option remoteip '10.0.1.100-254'
option is_nat '1'
option export_interface 'default'
option client_interface 'eth0'
option enabled '0'
option dns1 '10.0.1.1'
option dns2 '192.168.0.2'
config user
option enabled '1'
option ipaddress '*'
option username 'guest'
option password '123456'
+101
View File
@@ -0,0 +1,101 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2018-2020 Lienol <lawlienol@gmail.com>
START=99
CONFIG="pppoe-server"
CONFIG_FILE=/etc/ppp/$CONFIG-options
CHAP_SECRETS=/var/etc/chap-secrets
TEMP=/tmp/$CONFIG.tmp
config_t_get() {
local index=0
[ -n "$4" ] && index=$4
local ret=$(uci -q get $CONFIG.@$1[$index].$2 2>/dev/null)
echo ${ret:=$3}
}
setup_users() {
config_get enabled $1 enabled
[ "$enabled" -eq 0 ] && return 0
config_get username $1 username
config_get password $1 password
config_get ipaddress $1 ipaddress
[ -n "$username" -a -n "$password" ] && echo "$username $CONFIG $password $ipaddress" >> $CHAP_SECRETS
}
del_user()
{
cat $CHAP_SECRETS | grep -v $CONFIG > $TEMP
cat $TEMP > $CHAP_SECRETS
rm $TEMP
}
start() {
config_load pppoe-server
enabled=$(config_t_get service enabled)
[ "$enabled" -eq 0 ] && exit 0
cat <<-EOF >$CONFIG_FILE
# PPP options for the PPPoE server
# LIC: GPL
name $CONFIG
login
require-mschap-v2
refuse-chap
require-pap
lcp-echo-interval 10
lcp-echo-failure 2
mru $(config_t_get service mru 1492)
mtu $(config_t_get service mtu 1492)
ms-dns $(config_t_get service dns1 223.5.5.5)
ms-dns $(config_t_get service dns2 119.29.29.29)
logfile $(config_t_get service log /var/log/pppoe-server.log)
EOF
del_user
config_foreach setup_users user
ln -sfn $CHAP_SECRETS /etc/ppp/chap-secrets
local is_nat=$(config_t_get service is_nat)
local localip=$(config_t_get service localip)
if [ "$is_nat" -eq 1 ];then
local export_interface=$(config_t_get service export_interface)
if [ "$export_interface" != "default" ];then
iptables -t nat -A POSTROUTING -s ${localip%.*}.0/24 -o ${export_interface} -m comment --comment "PPPoE Server" -j MASQUERADE
else
iptables -t nat -A POSTROUTING -s ${localip%.*}.0/24 -m comment --comment "PPPoE Server" -j MASQUERADE
fi
iptables -A forwarding_rule -s ${localip%.*}.0/24 -m comment --comment "PPPoE Server" -j ACCEPT
fi
/usr/sbin/pppoe-server -k -I $(config_t_get service client_interface) -L $(config_t_get service localip) -R $(config_t_get service remoteip) -N $(config_t_get service count)
}
stop() {
del_user
nums=$(iptables -t nat -n -L POSTROUTING 2>/dev/null | grep -c "PPPoE Server")
if [ -n "$nums" ]; then
until [ "$nums" = 0 ]
do
rules=$(iptables -t nat -n -L POSTROUTING --line-num 2>/dev/null | grep "PPPoE Server" | awk '{print $1}')
for rule in $rules
do
iptables -t nat -D POSTROUTING $rule 2> /dev/null
break
done
nums=$(expr $nums - 1)
done
fi
nums2=$(iptables -L forwarding_rule 2>/dev/null | grep -c "PPPoE Server")
if [ -n "$nums2" ]; then
until [ "$nums2" = 0 ]
do
rules=$(iptables -L forwarding_rule --line-num 2>/dev/null | grep "PPPoE Server" | awk '{print $1}')
for rule in $rules
do
iptables -D forwarding_rule $rule 2> /dev/null
break
done
nums2=$(expr $nums2 - 1)
done
fi
ps | grep "pppd plugin rp-pppoe.so" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
kill -q -9 `pidof pppoe-server | sed "s/$$//g"`
}
@@ -0,0 +1,11 @@
{
"luci-app-pppoe-server": {
"description": "Grant UCI access for luci-app-pppoe-server",
"read": {
"uci": [ "pppoe-server" ]
},
"write": {
"uci": [ "pppoe-server" ]
}
}
}
@@ -0,0 +1,4 @@
{
"config": "pppoe-server",
"init": "pppoe-server"
}