🎈 Sync 2026-10-04 14:38:18

This commit is contained in:
github-actions[bot] committed 2026-10-04 14:38:18 +08:00
1 parent 0e6611f767
commit aba12667c5
88 files changed
+4600 -1458

No files matched your search

@@ -1,41 +0,0 @@
config openvpn 'myvpn'
option enabled '0'
option proto 'tcp4'
option dev 'tun'
option topology 'subnet'
option server '10.8.0.0 255.255.255.0'
option comp_lzo 'adaptive'
option ca '/etc/openvpn/pki/ca.crt'
option dh '/etc/openvpn/pki/dh.pem'
option cert '/etc/openvpn/pki/server.crt'
option key '/etc/openvpn/pki/server.key'
option persist_key '1'
option persist_tun '1'
option max_clients '88'
option keepalive '10 120'
option verb '3'
option status '/var/log/openvpn_status.log'
option log '/tmp/openvpn.log'
option port '1194'
option ddns 'myserver.f3322.net'
option auth_user_pass_verify '/etc/openvpn/server/checkpsw.sh via-env'
option script_security '3'
list push 'route 192.168.9.0 255.255.255.0'
list push 'comp-lzo adaptive'
list push 'redirect-gateway def1 bypass-dhcp'
list push 'dhcp-option DNS 192.168.9.1'
config openvpn 'client1'
option enabled '0'
option config '/etc/openvpn/client1.conf'
config openvpn 'client2'
option enabled '0'
option config '/etc/openvpn/client2.conf'
config openvpnpassword 'pwd1'
option pwdfile '/etc/openvpn/pass.txt'
config openvpnpassword 'pwd2'
option pwdfile '/etc/openvpn/pass2.txt'
@@ -1,10 +0,0 @@
set_var EASYRSA_OPENSSL "openssl"
set_var EASYRSA_KEY_SIZE 2048
set_var EASYRSA_REQ_COUNTRY "lunatickochiya"
set_var EASYRSA_REQ_PROVINCE "github"
set_var EASYRSA_REQ_CITY "github"
set_var EASYRSA_REQ_ORG "github"
set_var EASYRSA_REQ_EMAIL "lunatickochiya@github.com"
set_var EASYRSA_REQ_OU "github"
set_var EASYRSA_CA_EXPIRE 3650
set_var EASYRSA_CERT_EXPIRE 3650
@@ -0,0 +1,5 @@
#!/bin/sh
case "$ACTION" in
ifup|ifupdate) /usr/libexec/openvpn-client-cubic-route update >/dev/null 2>&1 ;;
esac
@@ -0,0 +1,29 @@
#!/bin/sh /etc/rc.common
START=89
STOP=10
USE_PROCD=1
start_service() {
local attempt=0
/usr/libexec/openvpn-client-cubic-route enabled || return 0
# OpenVPN starts at 90. Wait for DNS and the uplink before it connects.
while ! /usr/libexec/openvpn-client-cubic-route update; do
attempt=$((attempt + 1))
[ "$attempt" -lt 12 ] || {
logger -t openvpn-client-cubic 'Could not install CUBIC route before OpenVPN startup'
return 1
}
sleep 2
done
procd_open_instance
procd_set_param command /usr/libexec/openvpn-client-cubic-route watch
procd_set_param respawn 3600 5 -1
procd_close_instance
}
stop_service() {
/usr/libexec/openvpn-client-cubic-route clear
}
@@ -1,34 +1,52 @@
#!/bin/sh
function rand_str() {
rand_str() {
(base64 /dev/urandom | tr -dc 'A-Za-z' | head -c $1) 2>/dev/null
}
function rand_str_upper() {
rand_str_upper() {
(rand_str $1 | tr 'a-z' 'A-Z') 2>/dev/null
}
function rand_str_lower() {
rand_str_lower() {
(rand_str $1 | tr 'A-Z' 'a-z') 2>/dev/null
}
function rand_easy_rsa_vars() {
set_easy_rsa_var() {
local name="$1"
local value="$2"
if grep -q "^[[:space:]]*set_var[[:space:]]\+$name[[:space:]]" /etc/easy-rsa/vars; then
sed -i "s|^[[:space:]]*set_var[[:space:]]\+$name[[:space:]].*$|set_var $name\t$value|" /etc/easy-rsa/vars
else
printf 'set_var %s\t%s\n' "$name" "$value" >> /etc/easy-rsa/vars
fi
}
init_easy_rsa_vars() {
touch /etc/easy-rsa/vars
set_easy_rsa_var EASYRSA_OPENSSL '"openssl"'
set_easy_rsa_var EASYRSA_KEY_SIZE '2048'
set_easy_rsa_var EASYRSA_CA_EXPIRE '3650'
set_easy_rsa_var EASYRSA_CERT_EXPIRE '3650'
}
rand_easy_rsa_vars() {
local KEY_PROVINCE="$(rand_str_upper 6)"
local KEY_CITY="$(rand_str 8)"
local KEY_ORG="$(rand_str 8)"
local KEY_EMAIL="$(rand_str_lower 8)@$(rand_str_lower 4).$(rand_str_lower 3)"
local KEY_OU="$(rand_str 8)"
sed -i \
-e "s/^[[:space:]]*set_var[[:space:]]\+EASYRSA_REQ_COUNTRY[[:space:]]\+\".*\"$/set_var EASYRSA_REQ_COUNTRY\t\"$KEY_PROVINCE\"/" \
-e "s/^[[:space:]]*set_var[[:space:]]\+EASYRSA_REQ_PROVINCE[[:space:]]\+\".*\"$/set_var EASYRSA_REQ_PROVINCE\t\"$KEY_CITY\"/" \
-e "s/^[[:space:]]*set_var[[:space:]]\+EASYRSA_REQ_CITY[[:space:]]\+\".*\"$/set_var EASYRSA_REQ_CITY\t\"$KEY_ORG\"/" \
-e "s/^[[:space:]]*set_var[[:space:]]\+EASYRSA_REQ_ORG[[:space:]]\+\".*\"$/set_var EASYRSA_REQ_ORG\t\"$KEY_ORG\"/" \
-e "s/^[[:space:]]*set_var[[:space:]]\+EASYRSA_REQ_EMAIL[[:space:]]\+\".*\"$/set_var EASYRSA_REQ_EMAIL\t\"$KEY_EMAIL\"/" \
-e "s/^[[:space:]]*set_var[[:space:]]\+EASYRSA_REQ_OU[[:space:]]\+\".*\"$/set_var EASYRSA_REQ_OU\t\"$KEY_OU\"/" \
/etc/easy-rsa/vars
set_easy_rsa_var EASYRSA_REQ_COUNTRY "\"$KEY_PROVINCE\""
set_easy_rsa_var EASYRSA_REQ_PROVINCE "\"$KEY_CITY\""
set_easy_rsa_var EASYRSA_REQ_CITY "\"$KEY_ORG\""
set_easy_rsa_var EASYRSA_REQ_ORG "\"$KEY_ORG\""
set_easy_rsa_var EASYRSA_REQ_EMAIL "\"$KEY_EMAIL\""
set_easy_rsa_var EASYRSA_REQ_OU "\"$KEY_OU\""
}
init_easy_rsa_vars
rand_easy_rsa_vars
@@ -0,0 +1,4 @@
#!/bin/sh
/etc/init.d/openvpn-client-cubic enable
exit 0
@@ -1,6 +1,70 @@
#!/bin/sh
grep -qv "myvpn" /etc/config/openvpn && grep -q "myvpn" /etc/config/openvpn-opkg && cp -f /etc/config/openvpn-opkg /etc/config/openvpn
if ! uci -q get openvpn.myvpn >/dev/null; then
uci -q batch <<-EOF >/dev/null
set openvpn.myvpn=openvpn
set openvpn.myvpn.enabled='0'
set openvpn.myvpn.proto='tcp4'
set openvpn.myvpn.dev='tun'
set openvpn.myvpn.topology='subnet'
set openvpn.myvpn.server='10.8.0.0 255.255.255.0'
set openvpn.myvpn.comp_lzo='adaptive'
set openvpn.myvpn.ca='/etc/openvpn/pki/ca.crt'
set openvpn.myvpn.dh='/etc/openvpn/pki/dh.pem'
set openvpn.myvpn.cert='/etc/openvpn/pki/server.crt'
set openvpn.myvpn.key='/etc/openvpn/pki/server.key'
set openvpn.myvpn.persist_key='1'
set openvpn.myvpn.persist_tun='1'
set openvpn.myvpn.max_clients='88'
set openvpn.myvpn.keepalive='10 120'
set openvpn.myvpn.verb='3'
set openvpn.myvpn.status='/var/log/openvpn_status.log'
set openvpn.myvpn.log='/tmp/openvpn.log'
set openvpn.myvpn.port='1194'
set openvpn.myvpn.ddns='myserver.f3322.net'
set openvpn.myvpn.auth_user_pass_verify='/etc/openvpn/server/checkpsw.sh via-env'
set openvpn.myvpn.script_security='3'
add_list openvpn.myvpn.push='route 192.168.9.0 255.255.255.0'
add_list openvpn.myvpn.push='comp-lzo adaptive'
add_list openvpn.myvpn.push='redirect-gateway def1 bypass-dhcp'
add_list openvpn.myvpn.push='dhcp-option DNS 192.168.9.1'
commit openvpn
EOF
fi
if ! uci -q get openvpn.client1 >/dev/null; then
uci -q batch <<-EOF >/dev/null
set openvpn.client1=openvpn
set openvpn.client1.enabled='0'
set openvpn.client1.config='/etc/openvpn/client1.conf'
commit openvpn
EOF
fi
if ! uci -q get openvpn.client2 >/dev/null; then
uci -q batch <<-EOF >/dev/null
set openvpn.client2=openvpn
set openvpn.client2.enabled='0'
set openvpn.client2.config='/etc/openvpn/client2.conf'
commit openvpn
EOF
fi
if ! uci -q get openvpn.pwd1 >/dev/null; then
uci -q batch <<-EOF >/dev/null
set openvpn.pwd1=openvpnpassword
set openvpn.pwd1.pwdfile='/etc/openvpn/pass.txt'
commit openvpn
EOF
fi
if ! uci -q get openvpn.pwd2 >/dev/null; then
uci -q batch <<-EOF >/dev/null
set openvpn.pwd2=openvpnpassword
set openvpn.pwd2.pwdfile='/etc/openvpn/pass2.txt'
commit openvpn
EOF
fi
openvpn_port="$(uci -q get openvpn.myvpn.port)"
[ -z "$openvpn_port" ] && openvpn_port=1194