From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0278E138334 for ; Tue, 10 Jul 2018 21:11:22 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 14D76E0959; Tue, 10 Jul 2018 21:11:21 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E1061E0959 for ; Tue, 10 Jul 2018 21:11:20 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8E25F335CA8 for ; Tue, 10 Jul 2018 21:11:19 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 59E6F2E3 for ; Tue, 10 Jul 2018 21:11:17 +0000 (UTC) From: "Jason Donenfeld" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Jason Donenfeld" Message-ID: <1531257022.66af4525ff3a4530a165443f459134f1f60283f8.zx2c4@OpenRC> Subject: [gentoo-commits] proj/netifrc:master commit in: net/ X-VCS-Repository: proj/netifrc X-VCS-Files: net/Makefile net/wireguard.sh X-VCS-Directories: net/ X-VCS-Committer: zx2c4 X-VCS-Committer-Name: Jason Donenfeld X-VCS-Revision: 66af4525ff3a4530a165443f459134f1f60283f8 X-VCS-Branch: master Date: Tue, 10 Jul 2018 21:11:17 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 0a5969d9-528c-4149-ac3b-cc46b18607a9 X-Archives-Hash: a38cd05ba543a6f7f973283e6a06c317 commit: 66af4525ff3a4530a165443f459134f1f60283f8 Author: Jason A. Donenfeld gentoo org> AuthorDate: Sun May 27 23:56:51 2018 +0000 Commit: Jason Donenfeld gentoo org> CommitDate: Tue Jul 10 21:10:22 2018 +0000 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=66af4525 net/wireguard: import from ebuild Signed-off-by: Jason A. Donenfeld gentoo.org> net/Makefile | 2 +- net/wireguard.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/net/Makefile b/net/Makefile index 347e89c..390f8d8 100644 --- a/net/Makefile +++ b/net/Makefile @@ -14,7 +14,7 @@ INC-Linux= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \ ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \ ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \ vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh l2tp.sh \ - iw.sh + iw.sh wireguard.sh SRCS-NetBSD= ifwatchd.sh.in INC-NetBSD= ifwatchd.sh diff --git a/net/wireguard.sh b/net/wireguard.sh new file mode 100644 index 0000000..efa45b0 --- /dev/null +++ b/net/wireguard.sh @@ -0,0 +1,53 @@ +# Copyright (c) 2016 Gentoo Foundation +# Released under the 2-clause BSD license. + +wireguard_depend() +{ + program /usr/bin/wg + after interface +} + +wireguard_pre_start() +{ + [ "${IFACE#wg}" != "$IFACE" ] || return 0 + + ip link delete dev "$IFACE" type wireguard 2>/dev/null + ebegin "Creating WireGuard interface $IFACE" + if ! ip link add dev "$IFACE" type wireguard; then + e=$? + eend $e + return $e + fi + eend 0 + + ebegin "Configuring WireGuard interface $IFACE" + set -- $(_get_array "wireguard_$IFVAR") + if [ $# -eq 1 ]; then + /usr/bin/wg setconf "$IFACE" "$1" + else + eval /usr/bin/wg set "$IFACE" "$@" + fi + e=$? + if [ $e -eq 0 ]; then + _up + e=$? + if [ $e -eq 0 ]; then + eend $e + return $e + fi + fi + ip link delete dev "$IFACE" type wireguard 2>/dev/null + eend $e + return $e +} + +wireguard_post_stop() +{ + [ "${IFACE#wg}" != "$IFACE" ] || return 0 + + ebegin "Removing WireGuard interface $IFACE" + ip link delete dev "$IFACE" type wireguard + e=$? + eend $e + return $e +}