Merge pull request #60 from ifupdown-ng/feature/wireguard
wireguard executor implementation
This commit is contained in:
commit
a59109cb66
6 changed files with 70 additions and 2 deletions
3
Makefile
3
Makefile
|
@ -84,7 +84,8 @@ EXECUTOR_SCRIPTS_OPT ?= \
|
|||
bridge \
|
||||
vrf \
|
||||
tunnel \
|
||||
gre
|
||||
gre \
|
||||
wireguard
|
||||
|
||||
EXECUTOR_SCRIPTS ?= ${EXECUTOR_SCRIPTS_CORE} ${EXECUTOR_SCRIPTS_OPT}
|
||||
|
||||
|
|
16
executor-scripts/linux/wireguard
Executable file
16
executor-scripts/linux/wireguard
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
[ -n "$VERBOSE" ] && set -x
|
||||
[ -z "$IF_WIREGUARD_CONFIG_PATH" ] && IF_WIREGUARD_CONFIG_PATH="/etc/wireguard/$IFACE.conf"
|
||||
|
||||
case "$PHASE" in
|
||||
pre-up)
|
||||
${MOCK} ip link add $IFACE type wireguard
|
||||
${MOCK} wg setconf $IFACE $IF_WIREGUARD_CONFIG_PATH
|
||||
;;
|
||||
post-down)
|
||||
${MOCK} ip link delete dev $IFACE
|
||||
;;
|
||||
esac
|
9
tests/fixtures/wireguard.interfaces
vendored
Normal file
9
tests/fixtures/wireguard.interfaces
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
iface eth0
|
||||
address 203.0.113.2/24
|
||||
gateway 203.0.113.1
|
||||
|
||||
auto wg0
|
||||
iface wg0
|
||||
use wireguard
|
||||
address 1.2.3.4/24
|
||||
requires eth0
|
|
@ -33,7 +33,8 @@ tests_init \
|
|||
gre_dependency \
|
||||
vlan_explicit_learned_dependency \
|
||||
vlan_guessed_learned_dependency \
|
||||
vlan_complex_learned_dependency
|
||||
vlan_complex_learned_dependency \
|
||||
wireguard
|
||||
|
||||
noargs_body() {
|
||||
atf_check -s exit:1 -e ignore ifquery -S/dev/null
|
||||
|
@ -218,3 +219,10 @@ vlan_complex_learned_dependency_body() {
|
|||
-o match:"vlan-raw-device eth0" \
|
||||
ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vlan-complex.interfaces servers
|
||||
}
|
||||
|
||||
wireguard_body() {
|
||||
atf_check -s exit:0 \
|
||||
-o match:"requires eth0" \
|
||||
-o match:"use wireguard" \
|
||||
ifquery -E $EXECUTORS_LINUX -i $FIXTURES/wireguard.interfaces wg0
|
||||
}
|
||||
|
|
|
@ -10,3 +10,4 @@ atf_test_program{name='vrf_test'}
|
|||
atf_test_program{name='ppp_test'}
|
||||
atf_test_program{name='tunnel_test'}
|
||||
atf_test_program{name='gre_test'}
|
||||
atf_test_program{name='wireguard_test'}
|
||||
|
|
33
tests/linux/wireguard_test
Executable file
33
tests/linux/wireguard_test
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env atf-sh
|
||||
|
||||
. $(atf_get_srcdir)/../test_env.sh
|
||||
EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/wireguard"
|
||||
|
||||
tests_init \
|
||||
pre_up \
|
||||
pre_up_specified_config \
|
||||
post_down
|
||||
|
||||
pre_up_body() {
|
||||
export IFACE=wg0 PHASE=pre-up MOCK=echo
|
||||
atf_check -s exit:0 \
|
||||
-o match:'ip link add wg0 type wireguard' \
|
||||
-o match:'wg setconf wg0 /etc/wireguard/wg0.conf' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
||||
pre_up_specified_config_body() {
|
||||
export IFACE=wg0 PHASE=pre-up MOCK=echo \
|
||||
IF_WIREGUARD_CONFIG_PATH=/etc/wireguard/vpn.conf
|
||||
atf_check -s exit:0 \
|
||||
-o match:'ip link add wg0 type wireguard' \
|
||||
-o match:'wg setconf wg0 /etc/wireguard/vpn.conf' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
||||
post_down_body() {
|
||||
export IFACE=wg0 PHASE=post-down MOCK=echo
|
||||
atf_check -s exit:0 \
|
||||
-o match:'ip link delete dev wg0' \
|
||||
${EXECUTOR}
|
||||
}
|
Loading…
Reference in a new issue