mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 15:38:40 +01:00
kcptun: add new package
kcptun is a stable & secure tunnel based on kcp with N:M multiplexing. https://github.com/xtaci/kcptun Signed-off-by: Dengfeng Liu <liudf0716@gmail.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
config kcptun
|
||||
option local_port 12948 # this port should be your service port
|
||||
option remote_ip 'your vps ip'
|
||||
option remote_port 29900
|
||||
option mode 'fast'
|
||||
option nocomp 1
|
||||
option sndwnd 128
|
||||
option rcvwnd 512
|
||||
option disabled 1 # set 0 to enable it
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2019 Dengfeng Liu
|
||||
|
||||
START=99
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=kcptun-c
|
||||
PROG=/usr/bin/${NAME}
|
||||
|
||||
validate_section_kcptun()
|
||||
{
|
||||
uci_load_validate "${NAME}" kcptun "$1" "$2" \
|
||||
'local_port:port' \
|
||||
'remote_ip:string' \
|
||||
'remote_port:port' \
|
||||
'mode:string' \
|
||||
'nocomp:bool' \
|
||||
'sndwnd:uinteger' \
|
||||
'rcvwnd:uinteger' \
|
||||
'disabled:bool'
|
||||
}
|
||||
|
||||
kcptun_instance()
|
||||
{
|
||||
[ "$2" = 0 ] || {
|
||||
echo "validation failed"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ "${disabled}" = "1" ] && return 1
|
||||
|
||||
[ "${local_port}" -gt 0 ] && [ "${local_port}" -lt 65536 ] || return 1
|
||||
|
||||
[ "${remote_port}" -gt 0 ] && [ "${remote_port}" -lt 65536 ] || return 1
|
||||
|
||||
[ -n "${remote_ip}" ] || {
|
||||
return 1
|
||||
}
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "${PROG}"
|
||||
procd_append_param command --localaddr ":${local_port}"
|
||||
procd_append_param command --remoteaddr "${remote_ip}:${remote_port}"
|
||||
[ -n "${mode}" ] && procd_append_param command --mode "${mode}"
|
||||
[ "${nocomp}" -eq 1 ] && procd_append_param command --nocomp
|
||||
[ "${sndwnd}" -gt 0 ] && procd_append_param command --sndwnd "${sndwnd}"
|
||||
[ "${rcvwnd}" -gt 0 ] && procd_append_param command --rcvwnd "${rcvwnd}"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service()
|
||||
{
|
||||
config_load "${NAME}"
|
||||
config_foreach validate_section_kcptun kcptun kcptun_instance
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
config kcptun
|
||||
option local_port 29900
|
||||
option target_ip '127.0.0.1'
|
||||
option target_port 12948 # this port should be your service port
|
||||
option mode 'fast'
|
||||
option nocomp 1
|
||||
option sndwnd 1024
|
||||
option rcvwnd 1024
|
||||
option disabled 1 # set 0 to enable it
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2019 Dengfeng Liu
|
||||
|
||||
START=99
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=kcptun-s
|
||||
PROG=/usr/bin/${NAME}
|
||||
|
||||
validate_section_kcptun()
|
||||
{
|
||||
uci_load_validate "${NAME}" kcptun "$1" "$2" \
|
||||
'local_port:port' \
|
||||
'target_ip:string' \
|
||||
'target_port:port' \
|
||||
'mode:string' \
|
||||
'nocomp:bool' \
|
||||
'sndwnd:uinteger' \
|
||||
'rcvwnd:uinteger' \
|
||||
'disabled:bool'
|
||||
}
|
||||
|
||||
kcptun_instance()
|
||||
{
|
||||
[ "$2" = 0 ] || {
|
||||
echo "validation failed"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ "${disabled}" = "1" ] && return 1
|
||||
|
||||
[ "${local_port}" -gt 0 ] && [ "${local_port}" -lt 65536 ] || return 1
|
||||
|
||||
[ "${target_port}" -gt 0 ] && [ "${target_port}" -lt 65536 ] || return 1
|
||||
|
||||
[ -n "${target_ip}" ] || {
|
||||
return 1
|
||||
}
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "${PROG}"
|
||||
procd_append_param command --listen ":${local_port}"
|
||||
procd_append_param command --target "${target_ip}:${target_port}"
|
||||
[ -n "${mode}" ] && procd_append_param command --mode "${mode}"
|
||||
[ "${nocomp}" -eq 1 ] && procd_append_param command --nocomp
|
||||
[ "${sndwnd}" -gt 0 ] && procd_append_param command --sndwnd "${sndwnd}"
|
||||
[ "${rcvwnd}" -gt 0 ] && procd_append_param command --rcvwnd "${rcvwnd}"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service()
|
||||
{
|
||||
config_load "${NAME}"
|
||||
config_foreach validate_section_kcptun kcptun kcptun_instance
|
||||
}
|
||||
Reference in New Issue
Block a user