openvpn: switch to ifctl use for #5862

This commit is contained in:
Franco Fichtner 2022-07-25 10:43:18 +02:00
parent 2e2e59c1d8
commit 386b4679b4
2 changed files with 15 additions and 9 deletions

View File

@ -2,5 +2,5 @@
/sbin/pfctl -i ${1} -Fs
/bin/rm -f /tmp/${1}_router
/bin/rm -f /tmp/${1}_routerv6
/usr/local/sbin/ifctl -4ci ${1}
/usr/local/sbin/ifctl -6ci ${1}

View File

@ -1,26 +1,32 @@
#!/bin/sh
ROUTERV4=
ROUTERV6=
if [ -n "${route_vpn_gateway}" ]; then
/bin/echo ${route_vpn_gateway} > /tmp/${1}_router
ROUTERV4="-a ${route_vpn_gateway}"
elif [ -n "${ifconfig_remote}" ]; then
/bin/echo ${ifconfig_remote} > /tmp/${1}_router
ROUTERV4="-a ${ifconfig_remote}"
elif [ -n "${ifconfig_local}" ]; then
# XXX: We can't reliably determine the tunnels endpoint, other than parsing ifconfig.
# Use our standard parser to request the tunnels other end. Eventually we could pass this to configd if
# needed, but openvpn has elevated rights anyway at the moment.
/usr/local/etc/inc/plugins.inc.d/openvpn/tunnel_endpoint.php ${1} > /tmp/${1}_router
ROUTERV4="-a $(/usr/local/etc/inc/plugins.inc.d/openvpn/tunnel_endpoint.php ${1})"
elif [ "${dev_type}" = "tun" -a -n "${5}" ]; then
/bin/echo ${5} > /tmp/${1}_router
ROUTERV4="-a ${5}"
fi
if [ -n "${route_ipv6_gateway_1}" ]; then
/bin/echo ${route_ipv6_gateway_1} > /tmp/${1}_routerv6
ROUTERV6="-a ${route_ipv6_gateway_1}"
elif [ -n "${ifconfig_ipv6_remote}" ]; then
/bin/echo ${ifconfig_ipv6_remote} > /tmp/${1}_routerv6
ROUTERV6="-a ${ifconfig_ipv6_remote}"
elif [ -n "${ifconfig_ipv6_local}" ]; then
/bin/echo ${ifconfig_ipv6_local} > /tmp/${1}_routerv6
ROUTERV6="-a ${ifconfig_ipv6_local}"
fi
/usr/local/sbin/ifctl -4rd ${ROUTERV4}
/usr/local/sbin/ifctl -6rd ${ROUTERV6}
/usr/local/sbin/configctl -d interface newip ${1}
exit 0