Rename package and rebuild opkg-feed
- Added luci-app-GO-wireguard (Luci app for Wireguard pulled from GoldenOrb)
This commit is contained in:
5
ipk-source/luci-app-go-wireguard/root/etc/config/wireguard
Executable file
5
ipk-source/luci-app-go-wireguard/root/etc/config/wireguard
Executable file
@@ -0,0 +1,5 @@
|
||||
|
||||
config settings 'settings'
|
||||
option enabled '0'
|
||||
option client '0'
|
||||
option server '0'
|
||||
36
ipk-source/luci-app-go-wireguard/root/etc/config/wireguard_recipes
Executable file
36
ipk-source/luci-app-go-wireguard/root/etc/config/wireguard_recipes
Executable file
@@ -0,0 +1,36 @@
|
||||
config wireguard_recipe b_client
|
||||
option _description "Wireguard Client"
|
||||
option _role "client"
|
||||
option client "1"
|
||||
option port "51280"
|
||||
option auto '0'
|
||||
option addresses ''
|
||||
option dns ''
|
||||
option privatekey ''
|
||||
option name ''
|
||||
option keepalive '25'
|
||||
option publickey ''
|
||||
option presharedkey ''
|
||||
option ips ''
|
||||
option ra_ips '1'
|
||||
option endpoint_host ''
|
||||
option sport '51280'
|
||||
option active '0'
|
||||
option udptunnel '0'
|
||||
option mtu '1280'
|
||||
|
||||
config wireguard_recipe b_server
|
||||
option _description "Wireguard Server"
|
||||
option _role "server"
|
||||
option client "0"
|
||||
option port "51280"
|
||||
option auto '0'
|
||||
option addresses ''
|
||||
option publickey ''
|
||||
option privatekey ''
|
||||
option usepre '0'
|
||||
option presharedkey ''
|
||||
option active '0'
|
||||
option udptunnel '0'
|
||||
option udpport '54321'
|
||||
option mtu '1280'
|
||||
92
ipk-source/luci-app-go-wireguard/root/etc/init.d/wireguard
Executable file
92
ipk-source/luci-app-go-wireguard/root/etc/init.d/wireguard
Executable file
@@ -0,0 +1,92 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
. /lib/functions.sh
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
START=99
|
||||
|
||||
log() {
|
||||
logger -t "WireGuard Init.d : " "$@"
|
||||
}
|
||||
|
||||
chk_zone() {
|
||||
local config=$1
|
||||
|
||||
config_get src $config src
|
||||
config_get dest $config dest
|
||||
if [ $src = "lan" -a $dest = "wg" ]; then
|
||||
uci set firewall."$config".dest="wan"
|
||||
uci commit firewall
|
||||
fi
|
||||
}
|
||||
|
||||
check_config () {
|
||||
log "Check Client Interfaces"
|
||||
uci delete network.wg0
|
||||
uci delete network.wg1
|
||||
uci commit network
|
||||
uci set network.wg0=interface
|
||||
uci set network.wg0.proto="wireguard"
|
||||
uci set network.wg0.auto="0"
|
||||
uci set network.wg0.private_key=""
|
||||
uci set network.wg0.listen_port=""
|
||||
uci add_list network.wg0.addresses=""
|
||||
uci set network.wg1=interface
|
||||
uci set network.wg1.proto="wireguard"
|
||||
uci set network.wg1.auto="0"
|
||||
uci set network.wg1.private_key=""
|
||||
uci set network.wg1.listen_port=""
|
||||
uci add_list network.wg1.addresses=""
|
||||
uci commit network
|
||||
|
||||
uci delete firewall.wgzone
|
||||
uci delete firewall.wgwforward
|
||||
uci delete firewall.wwgforward
|
||||
uci delete firewall.lwgforward
|
||||
uci delete firewall.wglforward
|
||||
uci commit firewall
|
||||
uci set firewall.wgzone=zone
|
||||
uci set firewall.wgzone.name="wg"
|
||||
uci set firewall.wgzone.forward="ACCEPT"
|
||||
uci set firewall.wgzone.output="ACCEPT"
|
||||
uci set firewall.wgzone.network="wg0 wg1"
|
||||
uci set firewall.wgzone.input="ACCEPT"
|
||||
uci set firewall.wgzone.masq="1"
|
||||
uci set firewall.wgzone.mtu_fix="1"
|
||||
uci commit firewall
|
||||
|
||||
config_load firewall
|
||||
config_foreach chk_zone forwarding
|
||||
|
||||
/etc/init.d/firewall restart
|
||||
}
|
||||
|
||||
chk_start() {
|
||||
local config=$1
|
||||
|
||||
config_get auto $config auto
|
||||
uci set wireguard."$config".active="0"
|
||||
uci commit wireguard
|
||||
if [ $auto = '1' ]; then
|
||||
/usr/lib/wireguard/startvpn.sh $config
|
||||
else
|
||||
/usr/lib/wireguard/stopvpn.sh $config
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
uci set wireguard.settings.client="0"
|
||||
uci set wireguard.settings.server="0"
|
||||
uci commit wireguard
|
||||
if [ ! -e /etc/openvpn ]; then
|
||||
mkdir /etc/openvpn
|
||||
fi
|
||||
check_config
|
||||
|
||||
config_load wireguard
|
||||
config_foreach chk_start wireguard
|
||||
if [ -e /etc/crontabs/root ]; then
|
||||
sed -i '/wireguard_watchdog/d' /etc/crontabs/root
|
||||
fi
|
||||
echo '* * * * * /usr/bin/wireguard_watchdog' >> /etc/crontabs/root
|
||||
/etc/init.d/cron restart
|
||||
}
|
||||
Reference in New Issue
Block a user