Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openvpn: use ifctl in link up/down scripts
- Loading branch information
Showing
2 changed files
with
15 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |