mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-29 14:45:13 +08:00
update 2026-07-28 01:38:11
This commit is contained in:
1 parent
20b786ab77
commit
25d570431d
6243 files changed
+2850542
No files matched your search
@@ -0,0 +1,3 @@
|
||||
|
||||
config softether
|
||||
option enabled '0'
|
||||
@@ -0,0 +1,89 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2016 Chen RuiWei <crwbak@gmail.com>
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
CONFIG="luci-app-softethervpn"
|
||||
IPT="iptables -w"
|
||||
|
||||
add_rule() {
|
||||
openvpnport=$(cat /usr/libexec/softethervpn/vpn_server.config 2>/dev/null | grep OpenVPN_UdpPortList | awk -F " " '{print $3}')
|
||||
[ -z "$openvpnport" ] && openvpnport=1194
|
||||
|
||||
${IPT} -N SOFTETHER_VPN-SERVER
|
||||
${IPT} -I INPUT -j SOFTETHER_VPN-SERVER
|
||||
|
||||
${IPT} -A SOFTETHER_VPN-SERVER -p udp -m multiport --dports 500,1701,4500 -m comment --comment "L2TP-IPSec" -j ACCEPT
|
||||
${IPT} -A SOFTETHER_VPN-SERVER -p udp --dport $openvpnport -m comment --comment "OpenVPN" -j ACCEPT
|
||||
${IPT} -A SOFTETHER_VPN-SERVER -p tcp --dport $openvpnport -m comment --comment "OpenVPN" -j ACCEPT
|
||||
${IPT} -A SOFTETHER_VPN-SERVER -p tcp --dport 5555 -j ACCEPT
|
||||
${IPT} -A SOFTETHER_VPN-SERVER -p tcp --dport 8888 -j ACCEPT
|
||||
${IPT} -A SOFTETHER_VPN-SERVER -p tcp --dport 992 -j ACCEPT
|
||||
${IPT} -t mangle -I OUTPUT -p udp -m multiport --sports 500,1701,4500 -m comment --comment "SOFTETHER_VPN-SERVER-L2TP-IPSec" -j RETURN
|
||||
${IPT} -t mangle -I OUTPUT -p udp --sport $openvpnport -m comment --comment "SOFTETHER_VPN-SERVER-OPENVPN" -j RETURN
|
||||
${IPT} -t mangle -I OUTPUT -p tcp --sport $openvpnport -m comment --comment "SOFTETHER_VPN-SERVER-OPENVPN" -j RETURN
|
||||
}
|
||||
|
||||
del_rule() {
|
||||
ipt_del() {
|
||||
for i in $(seq 1 $($1 -nL $2 | grep -c "SOFTETHER_VPN-SERVER")); do
|
||||
local index=$($1 --line-number -nL $2 | grep "SOFTETHER_VPN-SERVER" | head -1 | awk '{print $1}')
|
||||
$1 -w -D $2 $index 2>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
ipt_del "${IPT} -t mangle" "OUTPUT"
|
||||
ipt_del "${IPT}" "INPUT"
|
||||
|
||||
${IPT} -F SOFTETHER_VPN-SERVER 2>/dev/null
|
||||
${IPT} -X SOFTETHER_VPN-SERVER 2>/dev/null
|
||||
}
|
||||
|
||||
gen_include() {
|
||||
echo '#!/bin/sh' > /var/etc/$CONFIG.include
|
||||
extract_rules() {
|
||||
echo "*$1"
|
||||
iptables-save -t $1 | grep "SOFTETHER_VPN-SERVER" | \
|
||||
sed -e "s/^-A \(INPUT\)/-I \1 1/"
|
||||
echo 'COMMIT'
|
||||
}
|
||||
cat <<-EOF >> /var/etc/$CONFIG.include
|
||||
iptables-save -c | grep -v "SOFTETHER_VPN-SERVER" | iptables-restore -c
|
||||
iptables-restore -n <<-EOT
|
||||
$(extract_rules filter)
|
||||
EOT
|
||||
EOF
|
||||
return 0
|
||||
}
|
||||
|
||||
start_service() {
|
||||
enabled=$(uci -q get $CONFIG.@softether[0].enabled || echo "0")
|
||||
[ $enabled -ne 1 ] && return 0
|
||||
|
||||
procd_open_instance $CONFIG
|
||||
procd_set_param env LANG=en_US.UTF-8
|
||||
procd_set_param command /usr/libexec/softethervpn/vpnserver start --foreground
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
add_rule
|
||||
gen_include
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
#top -bn1 | grep "/usr/libexec/softethervpn" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
|
||||
/usr/libexec/softethervpn/vpnserver stop
|
||||
del_rule
|
||||
rm -rf /var/etc/$CONFIG.include
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger $CONFIG
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete firewall.luci_app_softethervpn
|
||||
set firewall.luci_app_softethervpn=include
|
||||
set firewall.luci_app_softethervpn.type=script
|
||||
set firewall.luci_app_softethervpn.path=/var/etc/luci-app-softethervpn.include
|
||||
set firewall.luci_app_softethervpn.reload=1
|
||||
EOF
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@luci-app-softethervpn[-1]
|
||||
add ucitrack luci-app-softethervpn
|
||||
set ucitrack.@luci-app-softethervpn[-1].init=luci-app-softethervpn
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
/etc/init.d/softethervpnserver stop 2>/dev/null
|
||||
/etc/init.d/softethervpnserver disable 2>/dev/null
|
||||
|
||||
rm -rf /tmp/luci-*cache
|
||||
exit 0
|
||||
Reference in new issue
Block a user