🌴 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

@@ -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"
}