mirror of
https://github.com/AuxXxilium/synology-wireguard.git
synced 2024-11-23 23:11:06 +07:00
Initial commit
Signed-off-by: Andreas Runfalk <andreas@runfalk.se>
This commit is contained in:
commit
f4876efbc3
11
INFO.sh
Executable file
11
INFO.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source /pkgscripts-ng/include/pkg_util.sh
|
||||||
|
|
||||||
|
package="WireGuard"
|
||||||
|
version="0.0.20190227"
|
||||||
|
displayname="WireGuard"
|
||||||
|
maintainer="Andreas Runfalk"
|
||||||
|
arch="$(pkg_get_platform)"
|
||||||
|
description="Adds WireGuard support for your Synology NAS."
|
||||||
|
[ "$(caller)" != "0 NULL" ] && return 0
|
||||||
|
pkg_dump_info
|
19
LICENSE
Normal file
19
LICENSE
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2019 Andreas Runfalk. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software")
|
||||||
|
, to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
|
||||||
|
, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
50
Makefile
Normal file
50
Makefile
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
WIREGUARD_VERSION ?= 0.0.20190227
|
||||||
|
LIBMNL_VERSION ?= 1.0.4
|
||||||
|
|
||||||
|
LIBMNL_TAR = libmnl-$(LIBMNL_VERSION).tar.bz2
|
||||||
|
LIBMNL_DIR = libmnl-$(LIBMNL_VERSION)
|
||||||
|
|
||||||
|
WIREGUARD_TAR = WireGuard-$(WIREGUARD_VERSION).tar.xz
|
||||||
|
WIREGUARD_DIR = WireGuard-$(WIREGUARD_VERSION)
|
||||||
|
|
||||||
|
WG_TARGET = $(WIREGUARD_DIR)/src/tools/wg
|
||||||
|
WG_QUICK_TARGET = $(WIREGUARD_DIR)/wg-quick
|
||||||
|
WG_MODULE_TARGET = $(WIREGUARD_DIR)/src/wireguard.ko
|
||||||
|
|
||||||
|
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
all: $(WG_TARGET) $(WG_QUICK_TARGET) $(WG_MODULE_TARGET)
|
||||||
|
|
||||||
|
$(LIBMNL_TAR):
|
||||||
|
wget https://netfilter.org/projects/libmnl/files/$(LIBMNL_TAR)
|
||||||
|
|
||||||
|
$(LIBMNL_DIR)/Makefile: $(LIBMNL_TAR)
|
||||||
|
tar -xf $(LIBMNL_TAR)
|
||||||
|
(cd $(LIBMNL_DIR) && ./configure --host=x86_64-unknown-linux-gnu --enable-static --target=arm-unknown-linux-gnueabi CC=$(CROSS_COMPILE)-gcc)
|
||||||
|
|
||||||
|
$(LIBMNL_DIR)/src/.libs/libmnl.a: $(LIBMNL_DIR)/Makefile
|
||||||
|
make -C $(LIBMNL_DIR)
|
||||||
|
|
||||||
|
$(WIREGUARD_TAR):
|
||||||
|
wget https://git.zx2c4.com/WireGuard/snapshot/$(WIREGUARD_TAR)
|
||||||
|
|
||||||
|
$(WIREGUARD_DIR)/src/Makefile: $(WIREGUARD_TAR)
|
||||||
|
tar -xf $(WIREGUARD_TAR)
|
||||||
|
|
||||||
|
$(WG_TARGET): $(LIBMNL_DIR)/src/.libs/libmnl.a $(WIREGUARD_DIR)/src/Makefile
|
||||||
|
CFLAGS=-I$(ROOT_DIR)/$(LIBMNL_DIR)/include LDFLAGS=-L$(ROOT_DIR)/$(LIBMNL_DIR)/src/.libs make -C $(WIREGUARD_DIR)/src/tools CC=$(CROSS_COMPILE)-gcc
|
||||||
|
|
||||||
|
$(WG_QUICK_TARGET): $(WIREGUARD_DIR)/src/Makefile
|
||||||
|
cp $(WIREGUARD_DIR)/src/tools/wg-quick/linux.bash $(WG_QUICK_TARGET)
|
||||||
|
|
||||||
|
$(WG_MODULE_TARGET):
|
||||||
|
make -C $(WIREGUARD_DIR)/src module ARCH=arm KERNELDIR=$(KSRC) EXTRA_CFLAGS="-DCONFIG_SYNO_BACKPORT_ARM_CRYPTO=1"
|
||||||
|
|
||||||
|
install: all
|
||||||
|
mkdir -p $(DESTDIR)/wireguard/
|
||||||
|
install $(WG_TARGET) $(DESTDIR)/wireguard/
|
||||||
|
install $(WG_QUICK_TARGET) $(DESTDIR)/wireguard/
|
||||||
|
install $(WG_MODULE_TARGET) $(DESTDIR)/wireguard/
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(LIBMNL_TAR) $(LIBMNL_DIR) $(WIREGUARD_TAR) $(WIREGUARD_DIR)
|
BIN
PACKAGE_ICON.PNG
Normal file
BIN
PACKAGE_ICON.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
PACKAGE_ICON_256.PNG
Executable file
BIN
PACKAGE_ICON_256.PNG
Executable file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
67
README.rst
Normal file
67
README.rst
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
WireGuard support for Synology NAS
|
||||||
|
==================================
|
||||||
|
This package adds WireGuard support for Synology NAS drives.
|
||||||
|
|
||||||
|
|
||||||
|
Disclaimer
|
||||||
|
----------
|
||||||
|
You use everything here at your own risk. I am responsible if this breaks your
|
||||||
|
NAS.
|
||||||
|
|
||||||
|
|
||||||
|
Compatibility list
|
||||||
|
------------------
|
||||||
|
The following drives have been tested:
|
||||||
|
|
||||||
|
===== ========= =========== ===========
|
||||||
|
Model Platform DSM Version Is working?
|
||||||
|
----- --------- ----------- -----------
|
||||||
|
D218j armada38x 6.2 Yes
|
||||||
|
===== ========= =========== ===========
|
||||||
|
|
||||||
|
|
||||||
|
Compiling
|
||||||
|
---------
|
||||||
|
I've used docker to compile everything as ``pkgscripts-ng`` clutters the file
|
||||||
|
system quite a bit. Start by setting up a new docker container and enter a bash
|
||||||
|
prompt inside it:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo docker create -it --privileged --name synobuild ubuntu
|
||||||
|
sudo docker start synobuild
|
||||||
|
sudo docker exec -it synobuild bash
|
||||||
|
|
||||||
|
Now we can setup the build toolchain inside the Docker container:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
apt-get install git python3 wget ca-certificates
|
||||||
|
git clone https://github.com/SynologyOpenSource/pkgscripts-ng
|
||||||
|
mkdir source
|
||||||
|
git clone https://github.com/runfalk/synology-wireguard /source/WireGuard
|
||||||
|
|
||||||
|
The next step is figuring out which platform and DSM version to compile for.
|
||||||
|
Using `this table <https://www.synology.com/en-global/knowledgebase/DSM/tutorial/General/What_kind_of_CPU_does_my_NAS_have>`_
|
||||||
|
you can figure out how the next command should look like. In my case it's:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pkgscripts-ng/EnvDeploy -p armada38x -v 6.2
|
||||||
|
|
||||||
|
Now we can build an SPK package:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pkgscripts-ng/PkgCreate.py -p armada38x -v 6.2 -S --build-opt=-J --print-log -c WireGuard
|
||||||
|
|
||||||
|
There should now be an SPK in ``/result_spk``
|
||||||
|
|
||||||
|
Credits
|
||||||
|
-------
|
||||||
|
I based a lot of this work on
|
||||||
|
`this guide <https://www.reddit.com/r/synology/comments/a2erre/guide_intermediate_how_to_install_wireguard_vpn/>`_
|
||||||
|
by Reddit user `akhener <https://www.reddit.com/user/akhener>`_. However, I had
|
||||||
|
to modify their instructions a lot since my NAS has an ARM which made cross
|
||||||
|
compilation a lot trickier.
|
8
SynoBuildConf/build
Normal file
8
SynoBuildConf/build
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
case ${MakeClean} in
|
||||||
|
[Yy][Ee][Ss])
|
||||||
|
make clean
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
make ${MAKE_FLAGS} KSRC=$KSRC CROSS_COMPILE=$CROSS_COMPILE ARCH=$ARCH
|
2
SynoBuildConf/depends
Normal file
2
SynoBuildConf/depends
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[default]
|
||||||
|
all="6.2"
|
50
SynoBuildConf/install
Normal file
50
SynoBuildConf/install
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
### Use PKG_DIR as working directory.
|
||||||
|
PKG_DIR=/tmp/_test_spk
|
||||||
|
rm -rf $PKG_DIR
|
||||||
|
mkdir -p $PKG_DIR
|
||||||
|
|
||||||
|
### get spk packing functions
|
||||||
|
source /pkgscripts-ng/include/pkg_util.sh
|
||||||
|
|
||||||
|
create_package_tgz() {
|
||||||
|
local package_tgz_dir=/tmp/_package_tgz
|
||||||
|
|
||||||
|
### clear destination directory
|
||||||
|
rm -rf $package_tgz_dir && mkdir -p $package_tgz_dir
|
||||||
|
|
||||||
|
### install needed file into PKG_DIR
|
||||||
|
make install DESTDIR="$package_tgz_dir"
|
||||||
|
|
||||||
|
### create package.tgz $1: source_dir $2: dest_dir
|
||||||
|
pkg_make_package $package_tgz_dir "${PKG_DIR}"
|
||||||
|
}
|
||||||
|
|
||||||
|
create_spk(){
|
||||||
|
local scripts_dir=$PKG_DIR/scripts
|
||||||
|
|
||||||
|
### Copy package center scripts to PKG_DIR
|
||||||
|
mkdir -p $scripts_dir
|
||||||
|
cp -av scripts/* $scripts_dir
|
||||||
|
|
||||||
|
### Copy package icon
|
||||||
|
cp -av PACKAGE_ICON*.PNG $PKG_DIR
|
||||||
|
|
||||||
|
### Generate INFO file
|
||||||
|
./INFO.sh > INFO
|
||||||
|
cp INFO $PKG_DIR/INFO
|
||||||
|
|
||||||
|
### Create the final spk.
|
||||||
|
# pkg_make_spk <source path> <dest path> <spk file name>
|
||||||
|
# Please put the result spk into /image/packages
|
||||||
|
# spk name functions: pkg_get_spk_name pkg_get_spk_unified_name pkg_get_spk_family_name
|
||||||
|
mkdir -p /image/packages
|
||||||
|
pkg_make_spk ${PKG_DIR} "/image/packages" $(pkg_get_spk_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
create_package_tgz
|
||||||
|
create_spk
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
20
scripts/start-stop-status
Executable file
20
scripts/start-stop-status
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
case $1 in
|
||||||
|
start)
|
||||||
|
/sbin/insmod $SYNOPKG_PKGDEST/wireguard/wireguard.ko
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
/sbin/rmmod $SYNOPKG_PKGDEST/wireguard/wireguard.ko
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
/sbin/lsmod | grep wireguard && exit 0 || exit 3
|
||||||
|
;;
|
||||||
|
killall)
|
||||||
|
;;
|
||||||
|
log)
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in New Issue
Block a user