1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-12 18:41:51 +00:00

Update OpenVPN to 2.6.9

This commit is contained in:
Ycarus (Yannick Chabanois) 2024-03-13 09:44:10 +01:00
parent ec22b7e248
commit 8c9688f82f
3 changed files with 79 additions and 44 deletions

View file

@ -9,14 +9,14 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=openvpn
PKG_VERSION:=2.6.5
PKG_RELEASE:=1
PKG_VERSION:=2.6.9
PKG_RELEASE:=10
PKG_SOURCE_URL:=\
https://build.openvpn.net/downloads/releases/ \
https://swupdate.openvpn.net/community/releases/
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_HASH:=e34efdb9a3789a760cfc91d57349dfb1e31da169c98c06cb490c6a8a015638e2
PKG_HASH:=e08d147e15b4508dfcd1d6618a1f21f1495f9817a8dadc1eddf0532fa116d7e3
PKG_MAINTAINER:=Magnus Kroken <mkroken@gmail.com>

View file

@ -7,10 +7,14 @@
$*
}
# Wrap user defined scripts on up/down events
# Wrap user defined scripts on up/down/route-up/route-pre-down/ipchange events
# Scriptp set with up/down/route-up/route-pre-down/ipchange in the openvpn config are also executed with the command=user_xxxx
case "$ACTION" in
up) command=$user_up ;;
down) command=$user_down ;;
route-up) command=$user_route_up ;;
route-pre-down) command=$user_route_pre_down ;;
ipchange) command=$user_ipchange ;;
*) command= ;;
esac
@ -20,3 +24,4 @@ if [ -n "$command" ]; then
fi
exit 0

View file

@ -10,22 +10,13 @@ STOP=10
USE_PROCD=1
PROG=/usr/sbin/openvpn
PATH_INSTANCE_DIR="/etc/openvpn"
LIST_SEP="
"
UCI_STARTED=
UCI_DISABLED=
version_over_5_4() {
MAJOR_VERSION=$(uname -r | awk -F '.' '{print $1}')
MINOR_VERSION=$(uname -r | awk -F '.' '{print $2}')
if [ $MAJOR_VERSION -ge 5 ] && [ $MINOR_VERSION -gt 13 ] || [ $MAJOR_VERSION -gt 5 ] ; then
return 0
else
return 1
fi
}
append_param() {
local s="$1"
local v="$2"
@ -154,6 +145,9 @@ openvpn_add_instance() {
local security="$4"
local up="$5"
local down="$6"
local route_up="$7"
local route_pre_down="$8"
local ipchange="$9"
local client=$(grep -qEx "client|tls-client" "$dir/$conf" && echo 1)
procd_open_instance "$name"
@ -169,12 +163,12 @@ openvpn_add_instance() {
${client:+--ipchange "/usr/libexec/openvpn-hotplug ipchange $name"} \
${up:+--setenv user_up "$up"} \
${down:+--setenv user_down "$down"} \
${route_up:+--setenv user_route_up "$route_up"} \
${route_pre_down:+--setenv user_route_pre_down "$route_pre_down"} \
${client:+${ipchange:+--setenv user_ipchange "$ipchange"}} \
--script-security "${security:-2}" \
$(openvpn_get_dev "$name" "$conf") \
$(openvpn_get_credentials "$name" "$conf")
if version_over_5_4; then
procd_append_param command "--mptcp"
fi
procd_set_param file "$dir/$conf"
procd_set_param term_timeout 15
procd_set_param respawn
@ -184,7 +178,7 @@ openvpn_add_instance() {
procd_close_instance
}
start_instance() {
start_uci_instance() {
local s="$1"
config_get config "$s" config
@ -195,18 +189,25 @@ start_instance() {
return 1
}
local up down script_security
local up down route_up route_pre_down ipchange script_security
config_get up "$s" up
config_get down "$s" down
config_get route_up "$s" route_up
config_get route_pre_down "$s" route_pre_down
config_get ipchange "$s" ipchange
config_get script_security "$s" script_security
[ ! -d "/var/run" ] && mkdir -p "/var/run"
if [ ! -z "$config" ]; then
append UCI_STARTED "$config" "$LIST_SEP"
[ -n "$script_security" ] || get_openvpn_option "$config" script_security script-security
[ -n "$up" ] || get_openvpn_option "$config" up up
[ -n "$down" ] || get_openvpn_option "$config" down down
openvpn_add_instance "$s" "${config%/*}" "$config" "$script_security" "$up" "$down"
[ -n "$route_up" ] || get_openvpn_option "$config" route_up route-up
[ -n "$route_pre_down" ] || get_openvpn_option "$config" route_pre_down route-pre-down
[ -n "$ipchange" ] || get_openvpn_option "$config" ipchange ipchange
openvpn_add_instance "$s" "${config%/*}" "$config" "$script_security" "$up" "$down" "$route_up" "$route_pre_down" "$ipchange"
return
fi
@ -216,7 +217,47 @@ start_instance() {
append_params "$s" $OPENVPN_PARAMS
append_list "$s" $OPENVPN_LIST
openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf" "$script_security" "$up" "$down"
openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf" "$script_security" "$up" "$down" "$route_up" "$route_pre_down" "$ipchange"
}
start_path_instances() {
local path name
for path in ${PATH_INSTANCE_DIR}/*.conf; do
[ -f "$path" ] && {
name="${path##*/}"
name="${name%.conf}"
start_path_instance "$name"
}
done
}
start_path_instance() {
local name="$1"
local path name up down route_up route_pre_down ipchange
path="${PATH_INSTANCE_DIR}/${name}.conf"
# don't start configs again that are already started by uci
if echo "$UCI_STARTED" | grep -qxF "$path"; then
logger -t openvpn "$name.conf already started"
return
fi
# don't start configs which are set to disabled in uci
if echo "$UCI_DISABLED" | grep -qxF "$path"; then
logger -t openvpn "$name.conf is disabled in /etc/config/openvpn"
return
fi
get_openvpn_option "$path" up up || up=""
get_openvpn_option "$path" down down || down=""
get_openvpn_option "$path" route_up route-up || route_up=""
get_openvpn_option "$path" route_pre_down route-pre-down || route_pre_down=""
get_openvpn_option "$path" ipchange ipchange || ipchange=""
openvpn_add_instance "$name" "${path%/*}" "$path" "" "$up" "$down" "$route_up" "$route_pre_down" "$ipchange"
}
start_service() {
@ -238,31 +279,20 @@ start_service() {
config_load 'openvpn'
if [ -n "$instance" ]; then
[ "$instance_found" -gt 0 ] || return
start_instance "$instance"
if [ "$instance_found" -gt 0 ]; then
start_uci_instance "$instance"
elif [ -f "${PATH_INSTANCE_DIR}/${instance}.conf" ]; then
start_path_instance "$instance"
fi
else
config_foreach start_instance 'openvpn'
config_foreach start_uci_instance 'openvpn'
local path name up down
for path in /etc/openvpn/*.conf; do
if [ -f "$path" ]; then
name="${path##*/}"; name="${name%.conf}"
# don't start configs again that are already started by uci
if echo "$UCI_STARTED" | grep -qxF "$path"; then
continue
# don't start configs which are set to disabled in uci
elif echo "$UCI_DISABLED" | grep -qxF "$path"; then
logger -t openvpn "$name.conf is disabled in /etc/config/openvpn"
continue
fi
get_openvpn_option "$path" up up || up=""
get_openvpn_option "$path" down down || down=""
openvpn_add_instance "$name" "${path%/*}" "$path" "" "$up" "$down"
fi
done
auto="$(uci_get openvpn globals autostart 1)"
if [ "$auto" = "1" ]; then
start_path_instances
else
logger -t openvpn "Autostart for configs in '$PATH_INSTANCE_DIR/*.conf' disabled"
fi
fi
}