]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg-quick: add support for openbsd kernel implementation
authorMatt Dunwoodie <ncon@noconroy.net>
Sun, 10 May 2020 08:06:14 +0000 (02:06 -0600)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 11 May 2020 04:10:02 +0000 (22:10 -0600)
Signed-off-by: Matt Dunwoodie <ncon@noconroy.net>
src/wg-quick/openbsd.bash

index 958490218859125d1e5ffd8393918c9ecb22f440..3b90df20ccafefb6b68a087a4a058940dbedd8d7 100755 (executable)
@@ -100,10 +100,25 @@ get_real_interface() {
 }
 
 add_if() {
-       export WG_TUN_NAME_FILE="/var/run/wireguard/$INTERFACE.name"
-       mkdir -p "/var/run/wireguard/"
-       cmd "${WG_QUICK_USERSPACE_IMPLEMENTATION:-wireguard-go}" tun
-       get_real_interface
+       local index
+       echo "find wg" | config -e /bsd 2>/dev/null | grep "wg count 1" >/dev/null
+       if [[ $? == 0 ]]; then
+               REAL_INTERFACE=""
+               index=0
+               while [[ $REAL_INTERFACE == "" ]]; do
+                       ifconfig wg$index create
+                       if [[ $? == 0 ]]; then
+                               $REAL_INTERFACE="wg$index"
+                       fi
+                       index=$((index+1))
+               done
+               echo "[+] Interface for $INTERFACE is $REAL_INTERFACE" >&2
+       else
+               export WG_TUN_NAME_FILE="/var/run/wireguard/$INTERFACE.name"
+               mkdir -p "/var/run/wireguard/"
+               cmd "${WG_QUICK_USERSPACE_IMPLEMENTATION:-wireguard-go}" tun
+               get_real_interface
+       fi
 }
 
 del_routes() {