mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add A Dead Simple VPN
This commit is contained in:
parent
cfe790f601
commit
bf39d8706e
10 changed files with 668 additions and 384 deletions
45
dsvpn/Makefile
Normal file
45
dsvpn/Makefile
Normal file
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# Copyright (C) 2019 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter project
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/jedisct1/dsvpn.git
|
||||
PKG_SOURCE_VERSION:=917910d5f66a6d9f3302931c9d34e0a255979cf0
|
||||
PKG_NAME:=dsvpn
|
||||
PKG_VERSION:=0.1.0-$(PKG_SOURCE_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+kmod-tun
|
||||
TITLE:=A Dead Simple VPN
|
||||
URL:=https://github.com/jedisct1/dsvpn
|
||||
SUBMENU:=VPN
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/dsvpn
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/dsvpn $(1)/usr/sbin/$(PKG_NAME)
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) init $(1)/etc/init.d/$(PKG_NAME)
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
touch $(1)/etc/config/dsvpn
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
84
dsvpn/init
Executable file
84
dsvpn/init
Executable file
|
@ -0,0 +1,84 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2019 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter project
|
||||
|
||||
START=90
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG_NAME=dsvpn
|
||||
PROG=/usr/sbin/${PROG_NAME}
|
||||
|
||||
_log() {
|
||||
logger -p daemon.info -t ${PROG_NAME} "$@"
|
||||
}
|
||||
|
||||
_err() {
|
||||
logger -p daemon.err -t ${PROG_NAME} "$@"
|
||||
}
|
||||
|
||||
validate_section() {
|
||||
uci_validate_section dsvpn dsvpn "${1}" \
|
||||
'enable:bool:0' \
|
||||
'key:string' \
|
||||
'host:host' \
|
||||
'port:port' \
|
||||
'dev:string' \
|
||||
'localip:host' \
|
||||
'remoteip:host'
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local enable key host port dev
|
||||
|
||||
validate_section "${1}" || {
|
||||
_err "validation failed"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ "${enable}" = "1" ] || return 1
|
||||
|
||||
[ -n "${key}" ] || return 1
|
||||
[ "${key}" != "secretkey" ] || return 1
|
||||
[ -n "${port}" ] || return 1
|
||||
[ -n "${dev}" ] || return 1
|
||||
|
||||
echo "${key}" > /tmp/${PROG_NAME}-${1}.key
|
||||
key=""
|
||||
|
||||
if [ "$(uci -q get network.omrvpn)" != "" ]; then
|
||||
uci -q set network.omrvpn.ifname=$dev
|
||||
uci -q commit
|
||||
fi
|
||||
|
||||
_log "starting ${PROG_NAME} ${1} instance $*"
|
||||
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command ${PROG} client \
|
||||
/tmp/${PROG_NAME}-${1}.key \
|
||||
$host \
|
||||
$port \
|
||||
$dev \
|
||||
${localip:+$localip} \
|
||||
${remoteip:+$remoteip}
|
||||
|
||||
|
||||
procd_set_param respawn 0 30 0
|
||||
procd_set_param file /tmp/${PROG_NAME}-${1}.key
|
||||
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
|
||||
procd_close_instance
|
||||
|
||||
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load dsvpn
|
||||
config_foreach start_instance dsvpn
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger dsvpn network
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue