├── luci-app-xkcptun
├── root
│ └── etc
│ │ └── uci-defaults
│ │ └── 90_luci_xkcptun
├── luasrc
│ ├── controller
│ │ └── xkcptun.lua
│ └── model
│ │ └── cbi
│ │ └── xkcptun.lua
└── Makefile
├── README.md
└── xkcptun
├── files
├── xkcptun.config
└── xkcptun_client.init
└── Makefile
/luci-app-xkcptun/root/etc/uci-defaults/90_luci_xkcptun:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | uci -q batch <<-EOF >/dev/null
4 | delete ucitrack.@xkcptun[-1]
5 | add ucitrack xkcptun
6 | set ucitrack.@xkcptun[-1].init=kcptun_client
7 | commit ucitrack
8 | EOF
9 |
10 | rm -f /tmp/luci-indexcache
11 | exit 0
--------------------------------------------------------------------------------
/luci-app-xkcptun/luasrc/controller/xkcptun.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (C) 2016 zhangzf@kunteng.org
2 | -- Licensed to the public under the GNU General Public License v3.
3 |
4 | module("luci.controller.xkcptun", package.seeall)
5 |
6 | function index()
7 | if not nixio.fs.access("/etc/config/xkcptun") then
8 | luci.sys.exec("touch /etc/config/xkcptun")
9 | end
10 |
11 | entry({"admin", "services", "xkcptun"}, cbi("xkcptun"), _("Xkcptun加速"), 40).index = true
12 | end
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | *xkcptun is in the openwrt package feed now and maintenance will happen there*
2 |
3 | OpenWrt-xkcptun
4 | =================
5 |
6 | This is an [OpenWrt](https://openwrt.org) package feed for [xkcptun](https://github.com/liudf0716/xkcptun).
7 |
8 | ### Where to download packages?
9 |
10 | Check the [release section](https://github.com/gigibox/openwrt-xkcptun/releases) for the most recent release!
11 |
12 | ### How to build a OpenWrt .ipk package?
13 |
14 | These commands show how to build an OpenWrt a package(ipk) of xkcptun
15 |
16 | cd openwrt
17 |
18 | echo "src-git xkcptun https://github.com/gigibox/openwrt-xkcptun.git" >> feeds.conf.default
19 |
20 | ./scripts/feeds update xkcptun
21 | ./scripts/feeds install -a -p xkcptun
22 |
23 |
24 | The xkcptun packages should now appear in menuconfig.
25 |
26 |
27 | make menuconfig
28 |
29 | Network ---> < M > xkcptun
30 |
31 | LuCI ---> 3. Applications ---> <*> luci-app-xkcptun
32 |
33 |
34 | Exit and save the settings. Then build the packages:
35 |
36 |
37 | make package/xkcptun/compile V=s
38 | make package/luci-app-xkcptun/compile V=s
39 |
40 |
41 | The ipk packages can now be found in `bin/.../packages/xkcptun/`
42 |
--------------------------------------------------------------------------------
/xkcptun/files/xkcptun.config:
--------------------------------------------------------------------------------
1 | config client
2 | option localinterface br-lan
3 | option localport 8801
4 | option remoteaddr 192.168.96.1
5 | option remoteport 2223
6 | option key aes
7 |
8 | # aes, aes-128, aes-192, salsa20, blowfish, twofish, cast5, 3des, tea, xtea, xor, none (default: "none")
9 | option crypt none
10 |
11 | # profiles: fast3, fast2, fast, normal (default: "fast")
12 | option mode fast3
13 |
14 | # maximum transmission unit for UDP packets (default: 1350)
15 | #option mtu 1350
16 |
17 | # send window size(num of packets) (default: 1024)
18 | #option sndwnd 1024
19 |
20 | # receive window size(num of packets) (default: 1024)
21 | #option rcvwnd 1024
22 |
23 | # reed-solomon erasure coding - datashard (default: 10)
24 | #option datashard 10
25 |
26 | # reed-solomon erasure coding - parityshard (default: 3)
27 | # option parityshard 3
28 |
29 | # DSCP(6bit) (default: 0)
30 | #option dscp 0
31 |
32 | # disable compression (default: true)
33 | #option nocomp 1
34 |
35 | # set ack no delay (default: false)
36 | #option acknodelay false
37 |
38 | # set all conn no delay (default: false)
39 | #option nodelay false
40 |
41 | # default 20
42 | #option interval 20
43 |
44 | # default 2
45 | #option resend 2
46 |
47 | # what's this ? (default 1)
48 | #option nc 1
49 |
50 | # default 4194304
51 | #option sockbuf 4194304
52 |
53 | # default 10
54 | #option keepalive 10
55 |
--------------------------------------------------------------------------------
/xkcptun/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2014-2017 ZengFei Zhang
3 | #
4 | # This is free software, licensed under the GNU General Public License v3.
5 | # See /LICENSE for more information.
6 | #
7 |
8 | include $(TOPDIR)/rules.mk
9 |
10 | PKG_NAME:=xkcptun
11 | PKG_VERSION:=0.4.409
12 | PKG_RELEASE:=1
13 |
14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 | PKG_SOURCE_URL:=https://github.com/liudf0716/xkcptun/releases/download/$(PKG_VERSION)/
16 | PKG_MD5SUM:=bd3c216165ae31a8fa580e5d866972ec
17 |
18 | PKG_INSTALL:=1
19 | PKG_BUILD_PARALLEL:=1
20 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)
21 |
22 | include $(INCLUDE_DIR)/package.mk
23 | include $(INCLUDE_DIR)/cmake.mk
24 |
25 | define Package/$(PKG_NAME)/Default
26 | SECTION:=net
27 | CATEGORY:=Network
28 | TITLE:=A Secure Tunnel Based On KCP with N:M Multiplexing
29 | URL:=https://github.com/liudf0716/xkcptun
30 | DEPENDS:=+libjson-c +libevent2
31 | endef
32 |
33 | Package/$(PKG_NAME) = $(Package/$(PKG_NAME)/Default)
34 | Package/$(PKG_NAME)-server = $(Package/$(PKG_NAME)/Default)
35 |
36 | define Package/$(PKG_NAME)/description
37 | Xkcptun is a secure tunnel based on KCP implemented in the C language. for embedded devices and low end boxes.
38 | endef
39 |
40 | Package/$(PKG_NAME)-server/description = $(Package/$(PKG_NAME)/description)
41 |
42 | define Package/$(PKG_NAME)/install
43 | $(INSTALL_DIR) $(1)/usr/bin $(1)/etc/config $(1)/etc/init.d
44 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/xkcp_client $(1)/usr/bin/xkcptun_client
45 | $(INSTALL_CONF) ./files/xkcptun.config $(1)/etc/config/xkcptun
46 | $(INSTALL_BIN) ./files/xkcptun_client.init $(1)/etc/init.d/xkcptun_client
47 | endef
48 |
49 | define Package/$(PKG_NAME)-server/install
50 | $(INSTALL_DIR) $(1)/usr/bin
51 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/xkcp_server $(1)/usr/bin
52 | endef
53 |
54 | $(eval $(call BuildPackage,$(PKG_NAME)))
55 | $(eval $(call BuildPackage,$(PKG_NAME)-server))
56 |
--------------------------------------------------------------------------------
/luci-app-xkcptun/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright © 2017 gigibox zhangzengfei@kunteng.org
2 | #
3 | # This program is free software; you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation; either version 2 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License along
14 | # with this program; if not, write to the Free Software Foundation, Inc.,
15 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 | #
17 | # The full GNU General Public License is included in this distribution in
18 | # the file called "COPYING".
19 |
20 | include $(TOPDIR)/rules.mk
21 |
22 | PKG_NAME:=luci-app-xkcptun
23 | PKG_VERSION:=1.0
24 | PKG_RELEASE:=2
25 |
26 | PKG_LICENSE:=GPL-3.0
27 |
28 | include $(INCLUDE_DIR)/package.mk
29 |
30 | define Package/luci-app-xkcptun
31 | SECTION:=luci
32 | CATEGORY:=LuCI
33 | SUBMENU:=3. Applications
34 | TITLE:=LuCI support for xkcptun
35 | URL:=https://github.com/liudf0716/xkcptun
36 | MAINTAINER:=Lars Gierth
37 | PKGARCH:=all
38 | DEPENDS:=+luci-base
39 | endef
40 |
41 | define Package/luci-app-xkcptun/description
42 | This package allows you to configure xkcptun using LuCI.
43 | endef
44 |
45 | define Build/Compile
46 | endef
47 |
48 | define Package/luci-app-xkcptun/postinst
49 | #!/bin/sh
50 | UCI_DEF_FILE=90_luci_xkcptun
51 | if [ -z "$${IPKG_INSTROOT}" ]; then
52 | if [ -f /etc/uci-defaults/$UCI_DEF_FILE ]; then
53 | ( . /etc/uci-defaults/$UCI_DEF_FILE ) && \
54 | rm -f /etc/uci-defaults/$UCI_DEF_FILE
55 | fi
56 | rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
57 | fi
58 | exit 0
59 | endef
60 |
61 | define Package/luci-app-xkcptun/install
62 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci
63 | $(CP) ./luasrc/* $(1)/usr/lib/lua/luci
64 | $(CP) ./root/* $(1)/
65 | endef
66 |
67 | $(eval $(call BuildPackage,luci-app-xkcptun))
68 |
--------------------------------------------------------------------------------
/xkcptun/files/xkcptun_client.init:
--------------------------------------------------------------------------------
1 | #!/bin/sh /etc/rc.common
2 | #
3 | # Author: zhangzf
4 | # Created Time: 2017.04.20
5 | #
6 | # This is free software, licensed under the GNU General Public License v3.
7 | # See /LICENSE for more information.
8 | #
9 |
10 | START=66
11 | USE_PROCD=1
12 |
13 | PROG_NAME="xkcptun_client"
14 | PROG_UCI_CONF="xkcptun"
15 | PROG_ENABLED=1
16 | PROG_COMMAND=$(which "$PROG_NAME")
17 | PROG_CONFIG_FILE="/var/etc/xkcptun-client.json"
18 |
19 | bool_to_string() {
20 | echo $([ "$1" -eq 1 ] && echo "true" || echo "false")
21 | }
22 |
23 | xkcptun_validate_section() {
24 | uci_validate_section xkcptun client "${1}" \
25 | 'enable:bool:1' \
26 | 'localinterface:string' \
27 | 'localport:uinteger' \
28 | 'remoteaddr:string' \
29 | 'remoteport:uinteger' \
30 | 'key:string' \
31 | 'crypt:string:none' \
32 | 'mode:string:fast' \
33 | 'mtu:uinteger:1350' \
34 | 'sndwnd:uinteger:1024' \
35 | 'rcvwnd:uinteger:1024' \
36 | 'datashard:uinteger:10' \
37 | 'parityshard:uinteger:3' \
38 | 'dscp:uinteger:0' \
39 | 'nocomp:bool:1' \
40 | 'acknodelay:bool:0' \
41 | 'nodelay:uinteger:0' \
42 | 'interval:uinteger:20' \
43 | 'resend:uinteger:2' \
44 | 'nc:uinteger:1' \
45 | 'sockbuf:uinteger:4194304' \
46 | 'keepalive:uinteger:10'
47 | }
48 |
49 |
50 | xkcptun_client() {
51 | local localinterface localport remoteaddr remoteport key crypt mode \
52 | mtu sndwnd rcvwnd datashard parityshard dscp nocomp acknodelay nodelay \
53 | interval resend nc sockbuf keepalive enable
54 |
55 | xkcptun_validate_section "${1}" || {
56 | echo "validation failed"
57 | return 1
58 | }
59 |
60 | PROG_ENABLED=${enable:-1}
61 |
62 | [ ! -d "/var/etc/" ] && mkdir -p /var/etc/
63 |
64 | cat <<-EOF >$PROG_CONFIG_FILE
65 | {
66 | "localinterface": "$localinterface",
67 | "localport": $localport,
68 | "remoteaddr": "$remoteaddr",
69 | "remoteport": $remoteport,
70 | "key": "$key",
71 | "crypt": "$crypt",
72 | "mode": "$mode",
73 | "mtu": $mtu,
74 | "sndwnd": $sndwnd,
75 | "rcvwnd": $rcvwnd,
76 | "datashard": $datashard,
77 | "parityshard": $parityshard,
78 | "dscp": $dscp,
79 | "nocomp": $(bool_to_string $nocomp),
80 | "acknodelay": $(bool_to_string $acknodelay),
81 | "nodelay": $nodelay,
82 | "interval": $interval,
83 | "resend": $resend,
84 | "nc": $nc,
85 | "sockbuf": $sockbuf,
86 | "keepalive": $keepalive
87 | }
88 | EOF
89 | }
90 |
91 | init_config() {
92 | config_load "$PROG_UCI_CONF"
93 |
94 | config_foreach xkcptun_client client
95 | }
96 |
97 | service_triggers() {
98 | procd_add_reload_trigger "$PROG_UCI_CONF"
99 | }
100 |
101 | start_service() {
102 | [ -z "$PROG_COMMAND" ] && {
103 | echo "$PROG_NAME commands not found!"
104 | return 1
105 | }
106 |
107 | init_config
108 |
109 | [ $PROG_ENABLED -eq 0 ] && return 0
110 |
111 | procd_open_instance
112 | procd_set_param command $PROG_COMMAND -c $PROG_CONFIG_FILE -f
113 | procd_set_param file "$PROG_UCI_CONF"
114 | procd_set_param respawn
115 | procd_close_instance
116 | }
--------------------------------------------------------------------------------
/luci-app-xkcptun/luasrc/model/cbi/xkcptun.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (C) 2017 zhangzengfei@kunteng.org
2 | -- Licensed to the public under the GNU General Public License v3.
3 |
4 | local sys = require "luci.sys"
5 | local opkg = require "luci.model.ipkg"
6 |
7 | local packageName = "xkcptun"
8 | local m, s
9 |
10 | if not opkg.status(packageName)[packageName] then
11 | return Map(packageName, translate("Xkcptun"), translate('Xkcptun 未安装到当前系统.'))
12 | end
13 |
14 | m = Map("xkcptun", translate("xkcptun"), translate("Xkcptun" ..
15 | "是用c语言实现的kcptun,专为openwrt,lede平台开发" ))
16 |
17 | s = m:section(TypedSection, "client", translate("客户端配置"))
18 | s.anonymous = true
19 | s.addremove = false
20 |
21 | s:tab("general", translate("基本设置"))
22 | s:tab("advanced", translate("高级设置"))
23 |
24 | -- 基本设置
25 | Enable = s:taboption("general", Flag, "enable", translate("启用"),translate("启用加速服务"))
26 | Enable.default = Enable.enabled
27 |
28 | LocalInterface = s:taboption("general", Value, "localinterface", translate("内网接口"), translate("指定程序监听的网络接口,默认'br-lan'"))
29 | LocalInterface.default = "br-lan"
30 | for _, e in ipairs(sys.net.devices()) do
31 | if e ~= "lo" then LocalInterface:value(e) end
32 | end
33 |
34 | LocalPort = s:taboption("general", Value, "localport", translate("监听端口"), translate("本地监听端口"))
35 | LocalPort.datatype = "port"
36 | LocalPort.rmempty = false
37 |
38 | ServerAddr = s:taboption("general", Value, "remoteaddr", translate("服务端地址"), translate("Xkcptun服务端地址"))
39 | ServerAddr.rmempty = false
40 |
41 | ServerPort = s:taboption("general", Value, "remoteport", translate("服务器端口"), translate("Xkcptun服务端绑定端口"))
42 | ServerPort.datatype = "port"
43 | ServerPort.rmempty = false
44 |
45 | Key = s:taboption("general", Value, "key", translate("会话秘钥"), translate("连接服务端的会话密码"))
46 | Key.rmempty = false
47 |
48 | -- 高级设置
49 | MTU = s:taboption("advanced", Value, "mtu", translate("MTU"), translate("maximum transmission unit for UDP packets"))
50 | MTU.datatype = "uinteger"
51 | MTU.placeholder=1350
52 | MTU.rmempty = true
53 |
54 | SendWnd = s:taboption("advanced", Value, "sndwnd", translate("sndwnd"), translate("send window size(num of packets)"))
55 | SendWnd.datatype = "uinteger"
56 | SendWnd.placeholder=1024
57 | SendWnd.rmempty = true
58 |
59 | RendWnd = s:taboption("advanced", Value, "rcvwnd", translate("rcvwnd"), translate("receive window size(num of packets)"))
60 | RendWnd.datatype = "uinteger"
61 | RendWnd.placeholder=1024
62 | RendWnd.rmempty = true
63 |
64 | DataShard = s:taboption("advanced", Value, "datashard", translate("datashard"), translate("reed-solomon erasure coding"))
65 | DataShard.datatype = "uinteger"
66 | DataShard.placeholder=10
67 | DataShard.rmempty = true
68 |
69 | Parityshard = s:taboption("advanced", Value, "parityshard", translate("parityshard"), translate("reed-solomon erasure coding"))
70 | Parityshard.datatype = "uinteger"
71 | Parityshard.placeholder=3
72 | Parityshard.rmempty = true
73 |
74 | DSCP = s:taboption("advanced", Value, "dscp", translate("dscp"), translate("DSCP(6bit)"))
75 | DSCP.datatype = "uinteger"
76 | DSCP.placeholder=0
77 | DSCP.rmempty = true
78 |
79 | NoComp = s:taboption("advanced", Flag, "nocomp", translate("nocomp"), translate("disable compression"))
80 | NoComp.default = NoComp.enabled
81 |
82 | AckNodelay = s:taboption("advanced", Flag, "acknodelay", translate("acknodelay"), translate("set ack no delay"))
83 | AckNodelay.default = AckNodelay.disabled
84 |
85 | Nodelay = s:taboption("advanced", Flag, "nodelay", translate("nodelay"), translate("set all conn no delay"))
86 | Nodelay.default = Nodelay.disabled
87 |
88 | return m
--------------------------------------------------------------------------------