Skip to content

Commit 9eda95d

Browse files
Matt Dunwoodiezx2c4
authored andcommitted
wg-quick: add support for openbsd kernel implementation
Signed-off-by: Matt Dunwoodie <ncon@noconroy.net>
1 parent d4a32c9 commit 9eda95d

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/wg-quick/openbsd.bash

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,25 @@ get_real_interface() {
100100
}
101101

102102
add_if() {
103-
export WG_TUN_NAME_FILE="/var/run/wireguard/$INTERFACE.name"
104-
mkdir -p "/var/run/wireguard/"
105-
cmd "${WG_QUICK_USERSPACE_IMPLEMENTATION:-wireguard-go}" tun
106-
get_real_interface
103+
local index
104+
echo "find wg" | config -e /bsd 2>/dev/null | grep "wg count 1" >/dev/null
105+
if [[ $? == 0 ]]; then
106+
REAL_INTERFACE=""
107+
index=0
108+
while [[ $REAL_INTERFACE == "" ]]; do
109+
ifconfig wg$index create
110+
if [[ $? == 0 ]]; then
111+
$REAL_INTERFACE="wg$index"
112+
fi
113+
index=$((index+1))
114+
done
115+
echo "[+] Interface for $INTERFACE is $REAL_INTERFACE" >&2
116+
else
117+
export WG_TUN_NAME_FILE="/var/run/wireguard/$INTERFACE.name"
118+
mkdir -p "/var/run/wireguard/"
119+
cmd "${WG_QUICK_USERSPACE_IMPLEMENTATION:-wireguard-go}" tun
120+
get_real_interface
121+
fi
107122
}
108123

109124
del_routes() {

0 commit comments

Comments
 (0)