Browse Source

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>
lilik-openwrt-22.03
Dengfeng Liu 5 years ago
parent
commit
1673595ee1
5 changed files with 204 additions and 0 deletions
  1. +74
    -0
      net/kcptun/Makefile
  2. +9
    -0
      net/kcptun/files/kcptun-c.conf
  3. +56
    -0
      net/kcptun/files/kcptun-c.init
  4. +9
    -0
      net/kcptun/files/kcptun-s.conf
  5. +56
    -0
      net/kcptun/files/kcptun-s.init

+ 74
- 0
net/kcptun/Makefile View File

@ -0,0 +1,74 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=kcptun
PKG_VERSION:=20190725
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/xtaci/kcptun/tar.gz/v${PKG_VERSION}?
PKG_HASH:=65c0d0d4f7e3bb3c3b91e23ff2eb6621455d6d376a4f17e6fb2017337ce711c1
PKG_MAINTAINER:=Dengfeng Liu <liudf0716@gmail.com>
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
GO_PKG:=github.com/xtaci/kcptun
include $(INCLUDE_DIR)/package.mk
include ../../lang/golang/golang-package.mk
define Package/kcptun/template
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=KCP-based Secure Tunnel
URL:=https://github.com/xtaci/kcptun
DEPENDS:=$(GO_ARCH_DEPENDS)
endef
define Package/kcptun-c
$(call Package/kcptun/template)
TITLE+= (client)
endef
define Package/kcptun-s
$(call Package/kcptun/template)
TITLE+= (server)
endef
define Package/kcptun/description
kcptun is a Stable & Secure Tunnel Based On KCP with N:M Multiplexing
endef
Package/kcptun-c/description = $(Package/kcptun/description)
Package/kcptun-s/description = $(Package/kcptun/description)
GO_PKG_LDFLAGS_X:=main.VERSION=$(PKG_VERSION)
GO_PKG_LDFLAGS:=-s -w
define Package/kcptun/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(2) $(1)/usr/bin/$(3)
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_CONF) ./files/$(3).conf $(1)/etc/config/$(3)
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) ./files/$(3).init $(1)/etc/init.d/$(3)
endef
define Package/kcptun-c/install
$(call Package/kcptun/install,$(1),client,kcptun-c)
endef
define Package/kcptun-s/install
$(call Package/kcptun/install,$(1),server,kcptun-s)
endef
$(eval $(call GoBinPackage,kcptun-c))
$(eval $(call BuildPackage,kcptun-c))
$(eval $(call GoBinPackage,kcptun-s))
$(eval $(call BuildPackage,kcptun-s))

+ 9
- 0
net/kcptun/files/kcptun-c.conf View File

@ -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

+ 56
- 0
net/kcptun/files/kcptun-c.init View File

@ -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
}

+ 9
- 0
net/kcptun/files/kcptun-s.conf View File

@ -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

+ 56
- 0
net/kcptun/files/kcptun-s.init View File

@ -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
}

Loading…
Cancel
Save