1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

New interface for Glorytun UDP VPN

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-12-03 11:23:57 +01:00
parent 9ceaa526a5
commit e4103cea03
8 changed files with 239 additions and 14 deletions

View file

@ -1,7 +1,7 @@
#!/bin/sh /etc/rc.common
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
# Copyright (C) 2015 ovh.com
# Copyright (C) 2017 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
# Copyright (C) 2017-2020 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
START=90
STOP=10
@ -19,22 +19,20 @@ _err() {
}
validate_section() {
uci_validate_section glorytun glorytun "${1}" \
uci_validate_section glorytun-udp glorytun-udp "${1}" \
'enable:bool:0' \
'mode:string' \
'key:string' \
'host:host' \
'port:port' \
'proto:string' \
'bind:string:0.0.0.0' \
'bindport:port' \
'mtu:uinteger:1450' \
'mtuauto:bool:0' \
'chacha20:bool:0' \
'chacha:bool:0' \
'dev:string'
}
start_instance() {
local enable key host port listener proto bind bindport mtu mtuauto chacha20 dev
local enable key host port listener proto mtuauto chacha dev mode
validate_section "${1}" || {
_err "validation failed"
@ -42,12 +40,12 @@ start_instance() {
}
[ "${enable}" = "1" ] || return 1
[ "${proto}" = "udp" ] || return 1
[ -n "${key}" ] || return 1
[ "${key}" != "secretkey" ] || return 1
[ -n "${port}" ] || return 1
[ -n "${dev}" ] || return 1
[ -n "${mode}" ] || return 1
echo "${key}" > /tmp/${PROG_NAME}-${1}.key
key=""
@ -62,15 +60,13 @@ start_instance() {
procd_open_instance
procd_set_param command ${PROG} \
${bind:+bind from "$bind"} \
${bindport:+port "$bindport"} \
${host:+to addr "$host"} \
${host:+bind ${mode} addr "$host"} \
${port:+port "$port"} \
${dev:+dev "$dev"} \
keyfile /tmp/${PROG_NAME}-${1}.key \
persist
[ "${chacha20}" = "1" ] && procd_append_param command chacha
[ "${chacha}" = "1" ] && procd_append_param command chacha
procd_set_param respawn 0 30 0
procd_set_param file /tmp/${PROG_NAME}-${1}.key
@ -104,8 +100,8 @@ add_glorytun_path() {
start_service() {
local dev
config_load glorytun
config_foreach start_instance glorytun
config_load glorytun-udp
config_foreach start_instance glorytun-udp
}
reload_service() {