Skip to content

Commit

Permalink
net/wireguard: add wireguard importer
Browse files Browse the repository at this point in the history
Signed-off-by: Albert I <[email protected]>
  • Loading branch information
zx2c4 authored and krasCGQ committed Jul 11, 2019
1 parent 81a7cab commit 3cb76ad
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions net/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wireguard/
1 change: 1 addition & 0 deletions net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ config INET
Short answer: say Y.

if INET
source "net/wireguard/Kconfig"
source "net/ipv4/Kconfig"
source "net/ipv6/Kconfig"
source "net/netlabel/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions net/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ obj-$(CONFIG_NET) += $(tmp-y)
obj-$(CONFIG_LLC) += llc/
obj-$(CONFIG_NET) += ethernet/ 802/ sched/ netlink/
obj-$(CONFIG_NETFILTER) += netfilter/
obj-$(CONFIG_WIREGUARD) += wireguard/
obj-$(CONFIG_INET) += ipv4/
obj-$(CONFIG_XFRM) += xfrm/
obj-$(CONFIG_UNIX) += unix/
Expand Down
1 change: 1 addition & 0 deletions scripts/Kbuild.include
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,4 @@ why = \

echo-why = $(call escsq, $(strip $(why)))
endif
$(shell cd "$(srctree)" && ./scripts/fetch-latest-wireguard.sh)
30 changes: 30 additions & 0 deletions scripts/fetch-latest-wireguard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -e
USER_AGENT="WireGuard-AndroidROMBuild/0.2 ($(uname -a))"

exec 9>.wireguard-fetch-lock
flock -n 9 || exit 0

[[ $(( $(date +%s) - $(stat -c %Y "net/wireguard/.check" 2>/dev/null || echo 0) )) -gt 86400 ]] || exit 0
[[ $(( $(date +%s) - $(stat -c %Y "net/wireguard/.noconnectivity" 2>/dev/null || echo 0) )) -gt 5 ]] || exit 0
ping -w 2 -4 -c 1 build.wireguard.com >/dev/null 2>&1 || { touch "net/wireguard/.noconnectivity"; echo "No internet detected, skipping WireGuard update." >&2; exit 0; }

while read -r distro package version _; do
if [[ $distro == upstream && $package == kmodtools ]]; then
VERSION="$version"
break
fi
done < <(curl -A "$USER_AGENT" -LSs --connect-timeout 30 https://build.wireguard.com/distros.txt)

[[ -n $VERSION ]]

if [[ -f net/wireguard/version.h && $(< net/wireguard/version.h) == *$VERSION* ]]; then
touch net/wireguard/.check
exit 0
fi

rm -rf net/wireguard
mkdir -p net/wireguard
curl -A "$USER_AGENT" -LsS --connect-timeout 30 "https://git.zx2c4.com/WireGuard/snapshot/WireGuard-$VERSION.tar.xz" | tar -C "net/wireguard" -xJf - --strip-components=2 "WireGuard-$VERSION/src"
sed -i 's/tristate/bool/;s/default m/default y/;' net/wireguard/Kconfig
touch net/wireguard/.check

0 comments on commit 3cb76ad

Please sign in to comment.