├── LICENSE
├── README.md
├── luci
├── luci-app-aria2_ra
│ ├── Makefile
│ ├── luci
│ │ ├── i18n
│ │ │ └── aria2_ra.zh-cn.po
│ │ └── model
│ │ │ └── cbi
│ │ │ └── aria2_ra.lua
│ └── root
│ │ ├── etc
│ │ ├── aria2
│ │ │ ├── aria2.conf
│ │ │ └── post
│ │ ├── config
│ │ │ └── aria2_ra
│ │ ├── init.d
│ │ │ └── aria2_ra
│ │ └── uci-defaults
│ │ │ └── luci-aria2_ra
│ │ ├── lib
│ │ └── upgrade
│ │ │ └── keep.d
│ │ │ └── luci-app-aria2_ra
│ │ └── usr
│ │ ├── bin
│ │ └── aria2ctl
│ │ └── share
│ │ ├── luci
│ │ └── menu.d
│ │ │ └── luci-app-aria2_ra.json
│ │ └── rpcd
│ │ └── acl.d
│ │ └── luci-app-aria2_ra.json
├── luci-app-udp2raw
│ ├── Makefile
│ ├── luci
│ │ ├── i18n
│ │ │ └── udp2raw.zh-cn.po
│ │ └── model
│ │ │ └── cbi
│ │ │ └── udp2raw.lua
│ └── root
│ │ ├── etc
│ │ ├── config
│ │ │ └── udp2raw
│ │ ├── init.d
│ │ │ └── udp2raw
│ │ └── uci-defaults
│ │ │ └── luci-udp2raw
│ │ └── usr
│ │ └── share
│ │ ├── luci
│ │ └── menu.d
│ │ │ └── luci-app-udp2raw.json
│ │ └── rpcd
│ │ └── acl.d
│ │ └── luci-app-udp2raw.json
└── luci-proto-tinyfecvpn
│ ├── Makefile
│ ├── luci
│ ├── htdocs
│ │ └── luci-static
│ │ │ └── resources
│ │ │ └── protocol
│ │ │ └── tinyfecvpn.js
│ ├── i18n
│ │ └── tinyfecvpn.zh-cn.po
│ └── model
│ │ └── cbi
│ │ └── network
│ │ └── proto_tinyfecvpn.lua
│ └── root
│ ├── etc
│ ├── hotplug.d
│ │ └── iface
│ │ │ └── 99-tinyfecvpn
│ └── tinyfecvpn
│ │ ├── client_down.sh
│ │ └── client_up.sh
│ ├── lib
│ ├── netifd
│ │ └── proto
│ │ │ └── tinyfecvpn.sh
│ └── upgrade
│ │ └── keep.d
│ │ └── tinyfecvpn
│ └── usr
│ ├── libexec
│ └── rpcd
│ │ └── luci.tinyfecvpn
│ └── share
│ └── rpcd
│ └── acl.d
│ └── luci.tinyfecvpn.json
└── package
├── tinyfecVPN
└── Makefile
└── udp2raw
└── Makefile
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 RA
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | my_openwrt_mod
2 | ==============
3 |
4 | Install
5 | -------
6 |
7 | Add this line to your feeds.conf.default.
8 |
9 | src-git-full ramod https://github.com/ravageralpha/my_openwrt_mod.git
10 |
11 | And run
12 |
13 | ./scripts/feeds update -a && ./scripts/feeds install -a
14 |
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/Makefile:
--------------------------------------------------------------------------------
1 | include $(TOPDIR)/rules.mk
2 |
3 | APP_NAME=aria2_ra
4 | PKG_NAME:=luci-app-$(APP_NAME)
5 | PKG_VERSION:=1.0
6 | PKG_RELEASE:=1
7 |
8 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
9 |
10 | include $(INCLUDE_DIR)/package.mk
11 |
12 | define Package/$(PKG_NAME)/Default
13 | SECTION:=luci
14 | CATEGORY:=RA-MOD
15 | SUBMENU:=LuCI
16 | TITLE:=LuCI Support for $(APP_NAME)
17 | PKGARCH:=all
18 | endef
19 |
20 | define Package/$(PKG_NAME)
21 | $(call Package/$(PKG_NAME)/Default)
22 | DEPENDS:=+luci-compat +aria2
23 | endef
24 |
25 | define Package/$(PKG_NAME)/description
26 | LuCI Support for $(APP_NAME).
27 | endef
28 |
29 | define Build/Prepare
30 | $(foreach po,$(wildcard ${CURDIR}/luci/i18n/*.po), \
31 | po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
32 | endef
33 |
34 | define Build/Configure
35 | endef
36 |
37 | define Build/Compile
38 | endef
39 |
40 | define Package/$(PKG_NAME)/postinst
41 | #!/bin/sh
42 | if [ -z "$${IPKG_INSTROOT}" ]; then
43 | if [ -f /etc/uci-defaults/luci-$(APP_NAME) ]; then
44 | ( . /etc/uci-defaults/luci-$(APP_NAME) ) && \
45 | rm -f /etc/uci-defaults/luci-$(APP_NAME)
46 | fi
47 | rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
48 | fi
49 | exit 0
50 | endef
51 |
52 | define Package/$(PKG_NAME)/conffiles
53 | /etc/config/$(APP_NAME)
54 | endef
55 |
56 | define Package/$(PKG_NAME)/install
57 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
58 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(APP_NAME).*.lmo $(1)/usr/lib/lua/luci/i18n/
59 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
60 | $(INSTALL_DATA) ./luci/model/cbi/*.lua $(1)/usr/lib/lua/luci/model/cbi/
61 | $(INSTALL_DIR) $(1)/; \
62 | cp -pR ./root/* $(1)/;
63 | endef
64 |
65 | $(eval $(call BuildPackage,$(PKG_NAME)))
66 |
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/luci/i18n/aria2_ra.zh-cn.po:
--------------------------------------------------------------------------------
1 | msgid "Authentication"
2 | msgstr "认证"
3 |
4 | msgid "BT/PT Max Peers"
5 | msgstr "BT/PT任务最大连接数"
6 |
7 | msgid "Basic Settings"
8 | msgstr "基本设置"
9 |
10 | msgid "Comment Using #"
11 | msgstr "注释用#"
12 |
13 | msgid "Default 5"
14 | msgstr "默认值: 5"
15 |
16 | msgid "Default 5 , Max 16"
17 | msgstr "默认 5线程, 最大16线程"
18 |
19 | msgid "Default 51413"
20 | msgstr "默认端口: 51413 (PT的尽量避免用传统端口,推荐默认)"
21 |
22 | msgid "Default Bytes"
23 | msgstr "默认单位为字节, 可加后缀 K 或 M (例如 250K 或 1M )"
24 |
25 | msgid "Device"
26 | msgstr "下载用的设备"
27 |
28 | msgid "Download Folder"
29 | msgstr "下载文件夹"
30 |
31 | msgid "Download Limit"
32 | msgstr "下载速度限制"
33 |
34 | msgid "Edit Configuration"
35 | msgstr "修改配置文件"
36 |
37 | msgid "Enable"
38 | msgstr "启动"
39 |
40 | msgid "Enable Disk Cache"
41 | msgstr "开启磁盘缓存"
42 |
43 | msgid "File Allocation Method"
44 | msgstr "文件分配方式"
45 |
46 | msgid "Max Concurrent Queue"
47 | msgstr "最大并发任务数"
48 |
49 | msgid "Max Thread"
50 | msgstr "下载线程"
51 |
52 | msgid "Minute"
53 | msgstr "分钟"
54 |
55 | msgid "Network"
56 | msgstr "网络设置"
57 |
58 | msgid "Recommand 25"
59 | msgstr "推荐 25, 太大会影响浏览网页速度"
60 |
61 | msgid "Seed Time"
62 | msgstr "做种时间"
63 |
64 | msgid "Settings"
65 | msgstr "基本设置"
66 |
67 | msgid "TCP Port"
68 | msgstr "TCP 端口"
69 |
70 | msgid "UDP Port"
71 | msgstr "UDP 端口"
72 |
73 | msgid "Upload Limit"
74 | msgstr "上传速度限制"
75 |
76 | msgid "Where Your Files Save"
77 | msgstr "保存下载文件的文件夹"
78 |
79 | msgid "You can customize aria2 configuration here"
80 | msgstr "可以在这里修改aria2的设置,详细请搜索aria2相关帮助文档"
81 |
82 | msgid "RPC secret authorization token"
83 | msgstr "RPC 令牌"
84 |
85 | msgid "aria2"
86 | msgstr "aria2"
87 |
88 | msgid "aria2 is not running,make sure you have mounted USB Storage device"
89 | msgstr "aria2未运行,请确保已挂载USB存储设备"
90 |
91 | msgid "aria2 is running"
92 | msgstr "aria2运行中"
93 |
94 | msgid "Run as User"
95 | msgstr "以用户运行"
96 |
97 | msgid "Run as Group"
98 | msgstr "以用户组运行"
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/luci/model/cbi/aria2_ra.lua:
--------------------------------------------------------------------------------
1 | local fs = require "nixio.fs"
2 | local util = require "nixio.util"
3 |
4 | local running=(luci.sys.call("pidof aria2c > /dev/null") == 0)
5 | yaaw=" "
6 | aria2_webui=" "
7 |
8 | if running then
9 | m = Map("aria2_ra", translate("aria2"), translate("aria2 is running") .. yaaw .. aria2_webui)
10 | else
11 | m = Map("aria2_ra", translate("aria2"), translate("aria2 is not running,make sure you have mounted USB Storage device"))
12 | end
13 |
14 | s = m:section(TypedSection, "aria2_ra", translate("Settings"))
15 | s.anonymous = true
16 |
17 | s:tab("basic", translate("Basic Settings"))
18 |
19 | switch = s:taboption("basic", Flag, "enabled", translate("Enable"))
20 | switch.rmempty = false
21 |
22 | user=s:taboption("basic", ListValue, "user", translate("Run as User"))
23 | local _user
24 | for i, _user in luci.util.vspairs(luci.util.split(luci.sys.exec("cat /etc/passwd | cut -f 1 -d :"))) do
25 | user:value(_user)
26 | end
27 | user.default = "root"
28 |
29 | group=s:taboption("basic", ListValue, "group", translate("Run as Group"))
30 | local _group
31 | for i, _group in luci.util.vspairs(luci.util.split(luci.sys.exec("cat /etc/group | cut -f 1 -d :"))) do
32 | group:value(_group)
33 | end
34 | group.default = "root"
35 |
36 | local devices = {}
37 | util.consume((fs.glob("/dev/sd??*")), devices)
38 |
39 | device = s:taboption("basic", ListValue, "device", translate("Device"))
40 | for i, dev in ipairs(devices) do
41 | device:value(dev)
42 | end
43 |
44 | download_folder = s:taboption("basic", Value, "download_folder", translate("Download Folder"), translate("Where Your Files Save"))
45 | download_folder.default = "Downloads"
46 | download_folder.placeholder = "Downloads"
47 |
48 | maxjobs = s:taboption("basic", Value, "maxjobs", translate("Max Concurrent Queue"), translate("Default 5"))
49 | maxjobs.default = "5"
50 | maxjobs.placeholder = "5"
51 | maxjobs.datatype = "uinteger"
52 |
53 | diskcache = s:taboption("basic", ListValue, "diskcache", translate("Enable Disk Cache"))
54 | diskcache:value("1M")
55 | diskcache:value("2M")
56 | diskcache:value("4M")
57 | diskcache:value("8M")
58 | diskcache:value("16M")
59 | diskcache:value("32M")
60 | diskcache:value("64M")
61 |
62 | s:tab("editconf", translate("Edit Configuration"))
63 | editconf = s:taboption("editconf", Value, "conf",
64 | translate("You can customize aria2 configuration here"),
65 | translate("Comment Using #"))
66 | editconf.template = "cbi/tvalue"
67 | editconf.rows = 20
68 | editconf.wrap = "off"
69 |
70 | function editconf.cfgvalue(self, section)
71 | return fs.readfile("/etc/aria2/aria2.conf") or ""
72 | end
73 | function editconf.write(self, section, value)
74 | if value then
75 | value = value:gsub("\r\n?", "\n")
76 | fs.writefile("/tmp/aria2.conf", value)
77 | if (luci.sys.call("cmp -s /tmp/aria2.conf /etc/aria2/aria2.conf") == 1) then
78 | fs.writefile("/etc/aria2/aria2.conf", value)
79 | end
80 | fs.remove("/tmp/aria2.conf")
81 | end
82 | end
83 |
84 | -- Network
85 | network=m:section(TypedSection, "aria2_ra", translate("Network"))
86 | network.anonymous = true
87 |
88 | maxthread = network:option(Value, "maxthread", translate("Max Thread"), translate("Default 5"))
89 | maxthread.default = "5"
90 | maxthread.placeholder = "5"
91 | maxthread.datatype = "uinteger"
92 |
93 | download_limit = network:option(Value, "download_limit", translate("Download Limit"), translate("Default Bytes"))
94 | download_limit.default = "0"
95 | download_limit.placeholder = "0"
96 |
97 | upload_limit = network:option(Value, "upload_limit", translate("Upload Limit"), translate("Default Bytes"))
98 | upload_limit.default = "0"
99 | upload_limit.placeholder = "0"
100 |
101 | tcp_port = network:option(Value, "tcp_port", translate("TCP Port"), translate("Default 51413"))
102 | tcp_port.default = "51413"
103 | tcp_port.placeholder = "51413"
104 | tcp_port.datatype = "portrange"
105 |
106 | udp_port = network:option(Value, "udp_port", translate("UDP Port"), translate("Default 51413"))
107 | udp_port.default = "51413"
108 | udp_port.placeholder = "51413"
109 | udp_port.datatype = "portrange"
110 |
111 | bt_maxpeers = network:option(Value, "btmaxpeers", translate("BT/PT Max Peers"), translate("Recommand 25"))
112 | bt_maxpeers.datatype = "uinteger"
113 | bt_maxpeers.default = "25"
114 | bt_maxpeers.placeholder = "25"
115 |
116 | seedtime = network:option(Value, "seedtime", translate("Seed Time"), translate("Minute"))
117 | seedtime.default = "525600"
118 | seedtime.placeholder = "525600"
119 | seedtime.datatype = "uinteger"
120 |
121 | -- Authentication
122 | rpc=m:section(TypedSection, "aria2_ra", translate("Authentication"))
123 | rpc.anonymous = true
124 | rpc_auth = rpc:option(Flag, "rpc_auth", translate("Enable"))
125 | rpc_auth.default = false
126 | rpc_auth.rmempty = false
127 | rpc_token = rpc:option(Value, "rpc_token", translate("RPC secret authorization token"))
128 |
129 | return m
130 |
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/root/etc/aria2/aria2.conf:
--------------------------------------------------------------------------------
1 | # General Setting
2 | continue
3 | peer-id-prefix=-TR2760-
4 | user-agent=Transmission/2.76 (13775)
5 | event-poll=epoll
6 | on-download-complete=/etc/aria2/post
7 | on-bt-download-complete=/etc/aria2/post
8 | save-session-interval=300
9 |
10 | # Connection Setting
11 | disable-ipv6
12 | check-certificate=false
13 | min-split-size=1M
14 |
15 | # BitTorrent Setting
16 | enable-dht6=false
17 | bt-seed-unverified
18 | bt-save-metadata
19 | bt-hash-check-seed
20 | bt-remove-unselected-file
21 | bt-request-peer-speed-limit=100K
22 | seed-ratio=0.0
23 |
24 | # RPC
25 | rpc-save-upload-metadata
26 |
27 |
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/root/etc/aria2/post:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # RA-MOD
3 | # aria2 post-process script
4 |
5 | urldecode(){
6 | echo -e "$(sed 's/+/ /g; s/%/\\x/g')"
7 | }
8 |
9 | getExtension(){
10 | echo $(sed 's/.*\.//')
11 | }
12 |
13 | # fix URL encoded filename
14 |
15 | rawfile="$3"
16 | newfile="$(dirname "$rawfile")/$(basename "$rawfile" | urldecode)"
17 |
18 | [ "$rawfile" != "$newfile" ] && mv "$rawfile" "$newfile"
19 |
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/root/etc/config/aria2_ra:
--------------------------------------------------------------------------------
1 | config aria2_ra config
2 | option enabled '0'
3 | option device '/dev/sda1'
4 | option download_folder 'Downloads'
5 | option diskcache '1M'
6 | option download_limit '0'
7 | option upload_limit '0'
8 | option btmaxpeers '25'
9 | option maxjobs '5'
10 | option maxthread '5'
11 | option tcp_port '51413'
12 | option udp_port '51413'
13 | option seedtime '525600'
14 | option rpc_auth '0'
15 | option user 'root'
16 | option group 'root'
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/root/etc/init.d/aria2_ra:
--------------------------------------------------------------------------------
1 | #!/bin/sh /etc/rc.common
2 |
3 | START=99
4 |
5 | SERVICE_USE_PID=1
6 | SERVICE_DAEMONIZE=1
7 | SERVICE_PID_FILE="/var/run/aria2c.pid"
8 | SERVICE_SIG="INT"
9 |
10 | start() {
11 |
12 | ulimit -n 1024
13 |
14 | config_load "aria2_ra"
15 | config_get enabled config enabled 0
16 |
17 | [ "$enabled" = 0 ] && return 0
18 |
19 | config_get device config device
20 |
21 | [ -z "$device" ] && exit 1
22 |
23 | mountpoint="`mount | grep "$device" | awk '{print $3}'`"
24 |
25 | [ -z "$mountpoint" ] && exit 1
26 |
27 | config_get download_folder config download_folder Downloads
28 | config_get diskcache config diskcache '1M'
29 | config_get download_limit config download_limit 0
30 | config_get upload_limit config upload_limit 0
31 | config_get btmaxpeers config btmaxpeers 25
32 | config_get maxjobs config maxjobs 5
33 | config_get maxthread config maxthread 5
34 | config_get tcp_port config tcp_port 51413
35 | config_get udp_port config udp_port 51413
36 | config_get seedtime config seedtime 525600
37 | config_get rpc_token config rpc_token
38 | config_get user config user "root"
39 | config_get group config group "root"
40 |
41 | aria2_conf_path="$mountpoint/.aria2"
42 | aria2_downloadlist="$aria2_conf_path/aria2file.txt"
43 | aria2_DHT="$aria2_conf_path/dht.dat"
44 | aria2_downloadfolder="$mountpoint/$download_folder"
45 |
46 | case "`mount | grep $device | cut -d' ' -f5`" in
47 | 'ext4')fileallocation="falloc";;
48 | *fat*)fileallocation="none";;
49 | *)fileallocation="trunc";;
50 | esac
51 |
52 | [ ! -d "$aria2_conf_path" ] && mkdir -p "$aria2_conf_path"
53 | [ ! -f "$aria2_downloadlist" ] && touch "$aria2_downloadlist"
54 | [ ! -f "$aria2_DHT" ] && touch "$aria2_DHT"
55 | [ -z "$rpc_token" ] && unset rpc_token
56 |
57 | aria2_configfile="/etc/aria2/aria2.conf"
58 | [ ! -f "$aria2_configfile" ] && {
59 | aria2_configfile="/etc/aria2/aria2.conf"
60 | cat > "$aria2_configfile" << EOF
61 | # General Setting
62 | continue
63 | peer-id-prefix=-TR2760-
64 | user-agent=Transmission/2.76 (13775)
65 | event-poll=epoll
66 | on-download-complete=/etc/aria2/post
67 | on-bt-download-complete=/etc/aria2/post
68 | save-session-interval=60
69 | force-save
70 |
71 | # Connection Setting
72 | disable-ipv6
73 | check-certificate=false
74 | min-split-size=1M
75 |
76 | # BitTorrent Setting
77 | enable-dht6=false
78 | bt-seed-unverified
79 | bt-save-metadata
80 | bt-hash-check-seed
81 | bt-remove-unselected-file
82 | bt-request-peer-speed-limit=100K
83 | bt-stop-timeout=1800
84 | seed-ratio=0.0
85 |
86 | # RPC
87 | rpc-save-upload-metadata
88 | EOF
89 | }
90 |
91 | ARGS="--conf-path="$aria2_configfile" \
92 | --dir="$aria2_downloadfolder" \
93 | --enable-rpc \
94 | --rpc-listen-all \
95 | --rpc-allow-origin-all \
96 | --listen-port=$tcp_port \
97 | --dht-listen-port=$udp_port \
98 | --file-allocation=$fileallocation \
99 | --input-file="$aria2_downloadlist" \
100 | --save-session="$aria2_downloadlist" \
101 | --dht-file-path="$aria2_DHT" \
102 | --seed-time=$seedtime \
103 | --disk-cache=$diskcache \
104 | --max-overall-download-limit=$download_limit \
105 | --max-overall-upload-limit=$upload_limit \
106 | --bt-max-peers=$btmaxpeers \
107 | --split=$maxthread \
108 | --max-connection-per-server=$maxthread \
109 | --max-concurrent-downloads=$maxjobs \
110 | ${rpc_token:+--rpc-secret="$rpc_token"}"
111 |
112 | chown -R "$user":"$group" "$aria2_conf_path"
113 | SERVICE_UID="$user"
114 | SERVICE_GID="$group"
115 | service_start /usr/bin/aria2c $ARGS
116 | }
117 |
118 | stop() {
119 | pgrep aria2c > $SERVICE_PID_FILE
120 | service_stop /usr/bin/aria2c
121 | }
122 |
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/root/etc/uci-defaults/luci-aria2_ra:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | uci -q batch <<-EOF >/dev/null
4 | delete ucitrack.@aria2_ra[-1]
5 | add ucitrack aria2_ra
6 | set ucitrack.@aria2_ra[-1].init=aria2_ra
7 | commit ucitrack
8 | EOF
9 |
10 | [ -n "${IPKG_INSTROOT}" ] || {
11 | chmod 755 /etc/init.d/aria2_ra >/dev/null 2>&1
12 | /etc/init.d/aria2_ra enable >/dev/null 2>&1
13 | }
14 |
15 | rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
16 | exit 0
17 |
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/root/lib/upgrade/keep.d/luci-app-aria2_ra:
--------------------------------------------------------------------------------
1 | /etc/aria2/
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/root/usr/bin/aria2ctl:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Author : RA
3 |
4 | [ -z `which wget` ] && echo "No wget" >&2 && exit 1
5 | [ -n `which openssl` ] && BASE64='openssl base64'
6 | [ -n `which base64` ] && BASE64='base64'
7 | [ -z "$BASE64" ] && echo "No base64/Openssl tools" >&2 && exit 1
8 |
9 | usage() {
10 | echo -e "Usage:
11 | -add [url]\t\tadd task
12 | -addTorrent [file]\tadd BitTorrent task
13 | -pause\t\t\tpause all task
14 | -resume\t\t\tresume all task
15 | -status\t\t\tget global status"
16 | }
17 |
18 | [ $# -eq 0 ] && usage
19 |
20 | aria2_getToken(){
21 | config_load "aria2"
22 | config_get rpc_token config rpc_token ""
23 | }
24 | . /lib/functions.sh
25 | aria2_getToken
26 | JSONPATH="http://127.0.0.1:6800/jsonrpc"
27 |
28 | if [ $# -ge 1 ]; then
29 |
30 | case "$1" in
31 | '-add')
32 | json="{\"jsonrpc\":\"2.0\", \"id\":\"RA\", \"method\":\"aria2.addUri\", \"params\":[\"token:"$rpc_token"\", [\""$2"\"]]}"
33 | ;;
34 | '-addTorrent')
35 | json="{\"jsonrpc\":\"2.0\", \"id\":\"RA\", \"method\":\"aria2.addTorrent\", \"params\":[\"token:"$rpc_token"\", \""`cat "$2" | "$BASE64"`"\"]}"
36 | ;;
37 | '-pause')
38 | json="{\"jsonrpc\":\"2.0\", \"id\":\"RA\", \"method\":\"aria2.pauseAll\", \"params\":[\"token:"$rpc_token"\"]}"
39 | ;;
40 | '-resume')
41 | json="{\"jsonrpc\":\"2.0\", \"id\":\"RA\", \"method\":\"aria2.unpauseAll\", \"params\":[\"token:"$rpc_token"\"]}"
42 | ;;
43 | '-status')
44 | json="{\"jsonrpc\":\"2.0\", \"id\":\"RA\", \"method\":\"aria2.getGlobalStat\", \"params\":[\"token:"$rpc_token"\"]}"
45 | ;;
46 | *)
47 | usage
48 | exit 1
49 | esac
50 |
51 | result=$(wget -qO- --header="Content-Type: application/json" --post-data="$json" "$JSONPATH")
52 | if [ -n "$result" ]; then
53 | case "$1" in
54 | -status)
55 |
56 | rawdata=$(echo "$result" | awk -F 'result":' '{print $2}' | sed -e 's/["{}]//g' | awk -v RS="," '{print}' | awk -F ':' '{print $2}')
57 |
58 | DOWNLOADSPEED="$(($(echo "$rawdata" | sed -n 1p)/1024))K"
59 | UPLOADSPEED="$(($(echo "$rawdata" | sed -n 6p)/1024))K"
60 | ActivedTask=$(echo "$rawdata" | sed -n 2p)
61 | WaitingTask=$(echo "$rawdata" | sed -n 5p)
62 |
63 | echo "DownloadSpeed:$DOWNLOADSPEED"
64 | echo "UploadSpeed:$UPLOADSPEED"
65 | echo "ActiveTask:$ActivedTask"
66 | echo "WaitingTask:$WaitingTask"
67 | ;;
68 | *)
69 | echo "Successful"
70 | ;;
71 | esac
72 | else
73 | echo "Fail" >&2
74 | fi
75 | fi
76 |
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/root/usr/share/luci/menu.d/luci-app-aria2_ra.json:
--------------------------------------------------------------------------------
1 | {
2 | "admin/services/aria2_ra": {
3 | "title": "aria2",
4 | "action": {
5 | "type": "cbi",
6 | "path": "aria2_ra",
7 | "post": { "cbi.submit": true }
8 | },
9 | "depends": {
10 | "acl": [ "luci-app-aria2_ra" ],
11 | "uci": { "aria2_ra": true }
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/luci/luci-app-aria2_ra/root/usr/share/rpcd/acl.d/luci-app-aria2_ra.json:
--------------------------------------------------------------------------------
1 | {
2 | "luci-app-aria2_ra": {
3 | "description": "Grant UCI access for luci-app-aria2_ra",
4 | "read": {
5 | "uci": [ "aria2-ra" ]
6 | },
7 | "write": {
8 | "uci": [ "aria2-ra" ]
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/luci/luci-app-udp2raw/Makefile:
--------------------------------------------------------------------------------
1 | include $(TOPDIR)/rules.mk
2 |
3 | APP_NAME=udp2raw
4 | PKG_NAME:=luci-app-$(APP_NAME)
5 | PKG_VERSION:=1.0
6 | PKG_RELEASE:=1
7 |
8 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
9 |
10 | include $(INCLUDE_DIR)/package.mk
11 |
12 | define Package/$(PKG_NAME)/Default
13 | SECTION:=luci
14 | CATEGORY:=RA-MOD
15 | SUBMENU:=LuCI
16 | TITLE:=LuCI Support for $(APP_NAME)
17 | PKGARCH:=all
18 | endef
19 |
20 | define Package/$(PKG_NAME)
21 | $(call Package/$(PKG_NAME)/Default)
22 | DEPENDS:=+luci-compat +udp2raw
23 | endef
24 |
25 | define Package/$(PKG_NAME)/description
26 | LuCI Support for $(APP_NAME).
27 | endef
28 |
29 | define Build/Prepare
30 | $(foreach po,$(wildcard ${CURDIR}/luci/i18n/*.po), \
31 | po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
32 | endef
33 |
34 | define Build/Configure
35 | endef
36 |
37 | define Build/Compile
38 | endef
39 |
40 | define Package/$(PKG_NAME)/postinst
41 | #!/bin/sh
42 | if [ -z "$${IPKG_INSTROOT}" ]; then
43 | if [ -f /etc/uci-defaults/luci-$(APP_NAME) ]; then
44 | ( . /etc/uci-defaults/luci-$(APP_NAME) ) && \
45 | rm -f /etc/uci-defaults/luci-$(APP_NAME)
46 | fi
47 | rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
48 | fi
49 | exit 0
50 | endef
51 |
52 | define Package/$(PKG_NAME)/conffiles
53 | /etc/config/$(APP_NAME)
54 | endef
55 |
56 | define Package/$(PKG_NAME)/install
57 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
58 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(APP_NAME).*.lmo $(1)/usr/lib/lua/luci/i18n/
59 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
60 | $(INSTALL_DATA) ./luci/model/cbi/*.lua $(1)/usr/lib/lua/luci/model/cbi/
61 | $(INSTALL_DIR) $(1)/; \
62 | cp -pR ./root/* $(1)/;
63 | endef
64 |
65 | $(eval $(call BuildPackage,$(PKG_NAME)))
66 |
--------------------------------------------------------------------------------
/luci/luci-app-udp2raw/luci/i18n/udp2raw.zh-cn.po:
--------------------------------------------------------------------------------
1 | msgid "udp2raw"
2 | msgstr "udp2raw"
3 |
4 | msgid "udp2raw is not running"
5 | msgstr "udp2raw 未启动"
6 |
7 | msgid "udp2raw is running"
8 | msgstr "udp2raw 已启动"
9 |
10 | msgid "Args"
11 | msgstr "命令"
12 |
--------------------------------------------------------------------------------
/luci/luci-app-udp2raw/luci/model/cbi/udp2raw.lua:
--------------------------------------------------------------------------------
1 | local fs = require "nixio.fs"
2 |
3 | local running=(luci.sys.call("pidof udp2raw > /dev/null") == 0)
4 | if running then
5 | m = Map("udp2raw", translate("udp2raw"), translate("udp2raw is running"))
6 | else
7 | m = Map("udp2raw", translate("udp2raw"), translate("udp2raw is not running"))
8 | end
9 |
10 | s = m:section(TypedSection, "udp2raw", "")
11 | s.anonymous = true
12 |
13 | switch = s:option(Flag, "enabled", translate("Enable"))
14 | switch.rmempty = false
15 |
16 | options = s:option(Value, "args", translate("Args"))
17 | options.optional = false;
18 |
19 | return m
20 |
--------------------------------------------------------------------------------
/luci/luci-app-udp2raw/root/etc/config/udp2raw:
--------------------------------------------------------------------------------
1 |
2 | config udp2raw 'config'
3 | option enabled '0'
4 | option args ''
5 |
--------------------------------------------------------------------------------
/luci/luci-app-udp2raw/root/etc/init.d/udp2raw:
--------------------------------------------------------------------------------
1 | #!/bin/sh /etc/rc.common
2 |
3 | START=90
4 | STOP=15
5 |
6 | SERVICE_DAEMONIZE=1
7 |
8 | start()
9 | {
10 | config_load "udp2raw"
11 | config_get enabled config enabled 0
12 |
13 | [ "$enabled" = 0 ] && return 0
14 |
15 | config_get args config args
16 |
17 | service_start /usr/bin/udp2raw $args
18 | }
19 |
20 | stop()
21 | {
22 | service_stop /usr/bin/udp2raw
23 | }
24 |
--------------------------------------------------------------------------------
/luci/luci-app-udp2raw/root/etc/uci-defaults/luci-udp2raw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | uci -q batch <<-EOF >/dev/null
4 | delete ucitrack.@udp2raw[-1]
5 | add ucitrack udp2raw
6 | set ucitrack.@udp2raw[-1].init=udp2raw
7 | commit ucitrack
8 | EOF
9 |
10 | [ -n "${IPKG_INSTROOT}" ] || {
11 | chmod 755 /etc/init.d/udp2raw >/dev/null 2>&1
12 | /etc/init.d/udp2raw enable >/dev/null 2>&1
13 | }
14 |
15 | rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
16 |
17 | exit 0
18 |
--------------------------------------------------------------------------------
/luci/luci-app-udp2raw/root/usr/share/luci/menu.d/luci-app-udp2raw.json:
--------------------------------------------------------------------------------
1 | {
2 | "admin/services/udp2raw": {
3 | "title": "udp2raw",
4 | "action": {
5 | "type": "cbi",
6 | "path": "udp2raw",
7 | "post": { "cbi.submit": true }
8 | },
9 | "depends": {
10 | "acl": [ "luci-app-udp2raw" ],
11 | "uci": { "udp2raw": true }
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/luci/luci-app-udp2raw/root/usr/share/rpcd/acl.d/luci-app-udp2raw.json:
--------------------------------------------------------------------------------
1 | {
2 | "luci-app-udp2raw": {
3 | "description": "Grant UCI access for luci-app-udp2raw",
4 | "read": {
5 | "uci": [ "udp2raw" ]
6 | },
7 | "write": {
8 | "uci": [ "udp2raw" ]
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/Makefile:
--------------------------------------------------------------------------------
1 | include $(TOPDIR)/rules.mk
2 |
3 | APP_NAME=tinyfecvpn
4 | PKG_NAME:=luci-proto-$(APP_NAME)
5 | PKG_VERSION:=1.0
6 | PKG_RELEASE:=1
7 |
8 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
9 |
10 | include $(INCLUDE_DIR)/package.mk
11 |
12 | define Package/$(PKG_NAME)/Default
13 | SECTION:=luci
14 | CATEGORY:=RA-MOD
15 | SUBMENU:=LuCI
16 | TITLE:=LuCI Support for $(APP_NAME)
17 | PKGARCH:=all
18 | endef
19 |
20 | define Package/$(PKG_NAME)
21 | $(call Package/$(PKG_NAME)/Default)
22 | DEPENDS:=+luci-compat +tinyfecVPN
23 | endef
24 |
25 | define Package/$(PKG_NAME)/description
26 | LuCI Support for $(APP_NAME).
27 | endef
28 |
29 | define Build/Prepare
30 | $(foreach po,$(wildcard ${CURDIR}/luci/i18n/*.po), \
31 | po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
32 | endef
33 |
34 | define Build/Configure
35 | endef
36 |
37 | define Build/Compile
38 | endef
39 |
40 | define Package/$(PKG_NAME)/postinst
41 | #!/bin/sh
42 | if [ -z "$${IPKG_INSTROOT}" ]; then
43 | if [ -f /etc/uci-defaults/luci-$(APP_NAME) ]; then
44 | ( . /etc/uci-defaults/luci-$(APP_NAME) ) && \
45 | rm -f /etc/uci-defaults/luci-$(APP_NAME)
46 | fi
47 | rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
48 | fi
49 | exit 0
50 | endef
51 |
52 | define Package/$(PKG_NAME)/install
53 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
54 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(APP_NAME).*.lmo $(1)/usr/lib/lua/luci/i18n/
55 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/network
56 | $(INSTALL_DATA) ./luci/model/cbi/network/*.lua $(1)/usr/lib/lua/luci/model/cbi/network/
57 | $(INSTALL_DIR) $(1)/www/luci-static/resources/protocol
58 | $(INSTALL_DATA) ./luci/htdocs/luci-static/resources/protocol/*.js $(1)/www/luci-static/resources/protocol/
59 | $(INSTALL_DIR) $(1)/; \
60 | cp -pR ./root/* $(1)/;
61 | endef
62 |
63 | $(eval $(call BuildPackage,$(PKG_NAME)))
64 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/luci/htdocs/luci-static/resources/protocol/tinyfecvpn.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | 'require rpc';
3 | 'require form';
4 | 'require network';
5 |
6 | var callGetPostScript = rpc.declare({
7 | object: 'luci.tinyfecvpn',
8 | method: 'getScript',
9 | params: [ 'interface' ],
10 | expect: { '': {} }
11 | });
12 |
13 | var callSetPostScript = rpc.declare({
14 | object: 'luci.tinyfecvpn',
15 | method: 'setScript',
16 | params: [ 'interface', 'ifup', 'ifdown' ],
17 | expect: { '': {} }
18 | });
19 |
20 | return network.registerProtocol('tinyfecvpn', {
21 | getI18n: function() {
22 | return _('tinyFecVPN');
23 | },
24 |
25 | getIfname: function() {
26 | return this._ubus('l3_device') || 'vpn-%s'.format(this.sid);
27 | },
28 |
29 | getOpkgPackage: function() {
30 | return 'tinyfecvpn';
31 | },
32 |
33 | isFloating: function() {
34 | return true;
35 | },
36 |
37 | isVirtual: function() {
38 | return true;
39 | },
40 |
41 | getDevices: function() {
42 | return null;
43 | },
44 |
45 | containsDevice: function(ifname) {
46 | return (network.getIfnameOf(ifname) == this.getIfname());
47 | },
48 |
49 | renderFormOptions: function(s) {
50 | var dev = this.getDevice().getName(),
51 | LoadScript = null,
52 | o;
53 |
54 | o = s.taboption('general', form.Value, 'server', _('VPN Server'));
55 | o.optional = false;
56 | o.placeholder = "123.123.123.123:123"
57 |
58 | o = s.taboption('general', form.Value, 'passwd', _('Password'));
59 | o.password = true;
60 | o.optional = false;
61 |
62 | o = s.taboption('general', form.Value, 'fec', _('FEC'));
63 | o.default = "20:10"
64 | o.placeholder = "20:10"
65 |
66 | o = s.taboption('general', form.Value, 'subnet', _('Subnet'));
67 | o.default = "10.0.0.0"
68 | o.placeholder = "10.0.0.0"
69 | o.optional = false
70 |
71 | o = s.taboption('general', form.Value, 'extra', _('Extra Options'));
72 | o.placeholder = "--keep-reconnect 1";
73 |
74 | o = s.taboption('general', form.TextValue, 'ifup', _('Post Connection Script'));
75 | o.rows = 15;
76 | o.monospace = true;
77 | o.load = function(section_id) {
78 | LoadScript = LoadScript || callGetPostScript(section_id);
79 | return LoadScript.then(function(script) { return script.ifup });
80 | };
81 | o.write = function(section_id, value) {
82 | return callSetPostScript(section_id, value, null);
83 | };
84 |
85 | o = s.taboption('general', form.TextValue, 'ifdown', _('Post Disconnection Script'));
86 | o.rows = 15;
87 | o.monospace = true;
88 | o.load = function(section_id) {
89 | LoadScript = LoadScript || callGetPostScript(section_id);
90 | return LoadScript.then(function(script) { return script.ifdown });
91 | };
92 | o.write = function(section_id, value) {
93 | return callSetPostScript(section_id, null, value);
94 | };
95 | }
96 | });
97 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/luci/i18n/tinyfecvpn.zh-cn.po:
--------------------------------------------------------------------------------
1 | msgid ""
2 | msgstr "Content-Type: text/plain; charset=UTF-8"
3 |
4 | #: luci-proto-tinyfecvpn/htdocs/luci-static/resources/protocol/tinyfecvpn.js:73
5 | msgid "Extra Options"
6 | msgstr "自定义选项"
7 |
8 | #: luci-proto-tinyfecvpn/htdocs/luci-static/resources/protocol/tinyfecvpn.js:64
9 | msgid "FEC"
10 | msgstr "纠错包比例"
11 |
12 | #: luci-proto-tinyfecvpn/htdocs/luci-static/resources/protocol/tinyfecvpn.js:60
13 | msgid "Password"
14 | msgstr "服务器密码"
15 |
16 | #: luci-proto-tinyfecvpn/htdocs/luci-static/resources/protocol/tinyfecvpn.js:76
17 | msgid "Post Connection Script"
18 | msgstr "上线脚本"
19 |
20 | #: luci-proto-tinyfecvpn/htdocs/luci-static/resources/protocol/tinyfecvpn.js:87
21 | msgid "Post Disconnection Script"
22 | msgstr "下线脚本"
23 |
24 | #: luci-proto-tinyfecvpn/htdocs/luci-static/resources/protocol/tinyfecvpn.js:68
25 | msgid "Subnet"
26 | msgstr "本地子网"
27 |
28 | #: luci-proto-tinyfecvpn/htdocs/luci-static/resources/protocol/tinyfecvpn.js:56
29 | msgid "VPN Server"
30 | msgstr "服务器地址"
31 |
32 | #: luci-proto-tinyfecvpn/htdocs/luci-static/resources/protocol/tinyfecvpn.js:24
33 | #: luci-proto-tinyfecvpn/luasrc/model/network/proto_tinyfecvpn.lua:6
34 | msgid "tinyFecVPN"
35 | msgstr "tinyFecVPN"
36 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/luci/model/cbi/network/proto_tinyfecvpn.lua:
--------------------------------------------------------------------------------
1 | local netmod = luci.model.network
2 | local interface = luci.model.network.interface
3 | local proto = netmod:register_protocol("tinyfecvpn")
4 |
5 | function proto.get_i18n(self)
6 | return luci.i18n.translate("tinyFecVPN")
7 | end
8 |
9 | function proto.ifname(self)
10 | return "vpn-" .. self.sid
11 | end
12 |
13 | function proto.opkg_package(self)
14 | return "tinyfecvpn"
15 | end
16 |
17 | function proto.is_installed(self)
18 | return nixio.fs.access("/lib/netifd/proto/tinyfecvpn.sh")
19 | end
20 |
21 | function proto.is_floating(self)
22 | return true
23 | end
24 |
25 | function proto.is_virtual(self)
26 | return true
27 | end
28 |
29 | function proto.get_interface(self)
30 | return interface(self:ifname(), self)
31 | end
32 |
33 | function proto.get_interfaces(self)
34 | return nil
35 | end
36 |
37 | function proto.contains_interface(self, ifc)
38 | return (netmod:ifnameof(ifc) == self:ifname())
39 | end
40 |
41 | netmod:register_pattern_virtual("^vpn%-%w")
42 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/root/etc/hotplug.d/iface/99-tinyfecvpn:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | TEMPFILE=/var/etc/tinyfecvpn
3 |
4 | [ "$INTERFACE" = wan ] || exit 0
5 |
6 | [ -f "$TEMPFILE" ] || exit 0
7 |
8 | [ "$ACTION" = ifup -o "$ACTION" = ifupdate ] && ifup "$(cat $TEMPFILE)"
9 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/root/etc/tinyfecvpn/client_down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . /lib/netifd/netifd-proto.sh
3 |
4 | INTERFACE="$1"
5 | INTF="$2"
6 | SERVER=${3%:*}
7 |
8 | proto_init_update "$INTF" 0
9 | proto_send_update "$INTERFACE"
10 |
11 | ip route del $SERVER
12 |
13 | if [ -f /tmp/routes ]; then
14 | sed -i 's#route add#route del#g' /tmp/routes
15 | ip -batch /tmp/routes
16 | rm -f /tmp/routes
17 | fi
18 |
19 | echo $0 done
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/root/etc/tinyfecvpn/client_up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . /lib/netifd/netifd-proto.sh
3 |
4 | INTERFACE="$1"
5 | INTF="$2"
6 | SERVER=${3%:*}
7 | LOCAL_ADDR="${4%.*}.2"
8 | REMOTE_ADDR="${4%.*}.1"
9 | DEFAULT_GATEWAY="$(ip route show 0/0 | sort -k 7 | head -n 1 | sed -e 's/.* via \([^ ]*\).*/\1/')"
10 |
11 | proto_init_update "$INTF" 1
12 | proto_add_ipv4_address "$LOCAL_ADDR" 24 "" "$LOCAL_ADDR"
13 |
14 | proto_add_ipv4_route "0.0.0.0" 1 "$REMOTE_ADDR"
15 | proto_add_ipv4_route "128.0.0.0" 1 "$REMOTE_ADDR"
16 |
17 | ip route add $SERVER via $DEFAULT_GATEWAY
18 |
19 | chnroutes="/etc/chinadns_chnroute.txt"
20 | if [ -f "$chnroutes" ]; then
21 | sed -e "s/^/route add &/g" -e "s/$/ via $DEFAULT_GATEWAY/g" \
22 | $chnroutes > /tmp/routes
23 | ip -batch /tmp/routes
24 | fi
25 |
26 | proto_send_update "$INTERFACE"
27 |
28 | echo $0 done
29 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/root/lib/netifd/proto/tinyfecvpn.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . /lib/functions.sh
3 | . ../netifd-proto.sh
4 | init_proto "$@"
5 |
6 | proto_tinyfecvpn_init_config() {
7 | proto_config_add_string "server"
8 | proto_config_add_string "passwd"
9 | proto_config_add_string "fec"
10 | proto_config_add_string "subnet"
11 | proto_config_add_string "extra"
12 | no_device=1
13 | available=1
14 | }
15 |
16 | proto_tinyfecvpn_setup() {
17 | local config="$1"
18 |
19 | json_get_vars server passwd fec subnet extra
20 |
21 | grep -q tun /proc/modules || insmod tun
22 |
23 | logger -t tinyfecvpn "initializing..."
24 |
25 | proto_export INTERFACE="$config"
26 | logger -t tinyfecvpn "executing tinyfecVPN"
27 |
28 | proto_run_command "$config" \
29 | /usr/bin/tinyfecvpn -c \
30 | -r $server \
31 | -k $passwd \
32 | -f $fec \
33 | --manual-set-tun \
34 | --tun-dev vpn-$config \
35 | --sub-net $subnet \
36 | $extra
37 |
38 | [ -f "/etc/tinyfecvpn/client_up.sh" ] && {
39 | /bin/sh /etc/tinyfecvpn/client_up.sh \
40 | "$config" "vpn-$config" "$server" "$subnet"
41 | }
42 |
43 | mkdir -p /var/etc
44 | [ "$?" = 0 ] && echo "$config" > /var/etc/tinyfecvpn
45 | }
46 |
47 | proto_tinyfecvpn_teardown() {
48 | local config="$1"
49 | logger -t tinyfecvpn "bringing down tinyFecVPN"
50 | proto_kill_command "$config"
51 | [ -f "/etc/tinyfecvpn/client_down.sh" ] && {
52 | /bin/sh /etc/tinyfecvpn/client_down.sh \
53 | "$config" "vpn-$config" "$server"
54 | }
55 | rm -f /var/etc/tinyfecvpn
56 | }
57 |
58 | add_protocol tinyfecvpn
59 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/root/lib/upgrade/keep.d/tinyfecvpn:
--------------------------------------------------------------------------------
1 | /etc/tinyfecvpn/client_up.sh
2 | /etc/tinyfecvpn/client_down.sh
3 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/root/usr/libexec/rpcd/luci.tinyfecvpn:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env lua
2 |
3 | local json = require "luci.jsonc"
4 | local fs = require "nixio.fs"
5 |
6 | local function readfile(path)
7 | local s = fs.readfile(path)
8 | return s and (s:gsub("^%s+", ""):gsub("%s+$", ""))
9 | end
10 |
11 | local function writefile(path, data)
12 | local n = fs.writefile(path, data)
13 | return (n == #data)
14 | end
15 |
16 | local function parseInput()
17 | local parse = json.new()
18 | local done, err
19 |
20 | while true do
21 | local chunk = io.read(4096)
22 | if not chunk then
23 | break
24 | elseif not done and not err then
25 | done, err = parse:parse(chunk)
26 | end
27 | end
28 |
29 | if not done then
30 | print(json.stringify({ error = err or "Incomplete input" }))
31 | os.exit(1)
32 | end
33 |
34 | return parse:get()
35 | end
36 |
37 | if arg[1] == "list" then
38 | print(json.stringify({
39 | getScript = {
40 | interface = "interface"
41 | },
42 | setScript = {
43 | interface = "interface",
44 | ifup = "Post Connection Script",
45 | ifdown = "Post Disconnection Script",
46 | }
47 | }))
48 | elseif arg[1] == "call" then
49 | local args = parseInput()
50 |
51 | if not args.interface or
52 | type(args.interface) ~= "string" or
53 | not args.interface:match("^[a-zA-Z0-9_]+$")
54 | then
55 | print(json.stringify({ error = "Invalid interface name" }))
56 | os.exit(1)
57 | end
58 |
59 | if arg[2] == "getScript" then
60 | print(json.stringify({
61 | ifup = readfile("/etc/tinyfecvpn/client_up.sh"),
62 | ifdown = readfile("/etc/tinyfecvpn/client_down.sh")
63 | }))
64 | elseif arg[2] == "setScript" then
65 | if args.ifup then
66 | writefile("/etc/tinyfecvpn/client_up.sh")
67 | end
68 | if args.ifdown then
69 | writefile("/etc/tinyfecvpn/client_down.sh")
70 | end
71 | print(json.stringify({ result = true }))
72 | end
73 | end
74 |
--------------------------------------------------------------------------------
/luci/luci-proto-tinyfecvpn/root/usr/share/rpcd/acl.d/luci.tinyfecvpn.json:
--------------------------------------------------------------------------------
1 | {
2 | "luci-proto-tinyfecvpn": {
3 | "description": "Grant access to LuCI tinyFecVPN procedures",
4 | "read": {
5 | "ubus": {
6 | "luci.tinyfecvpn": [ "getScript" ]
7 | },
8 | "uci": [ "network" ]
9 | },
10 | "write": {
11 | "ubus": {
12 | "luci.tinyfecvpn": [ "setScript" ]
13 | },
14 | "uci": [ "network" ]
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/package/tinyfecVPN/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2017 Virtao
3 | #
4 | # This is free software, licensed under the MIT.
5 | # See /LICENSE for more information.
6 | #
7 |
8 | include $(TOPDIR)/rules.mk
9 |
10 | PKG_NAME:=tinyfecVPN
11 | PKG_VERSION:=20210116
12 | PKG_RELEASE:=1
13 |
14 | PKG_SOURCE_PROTO:=git
15 | PKG_SOURCE_URL:=https://github.com/wangyu-/tinyfecVPN.git
16 | PKG_SOURCE_VERSION:=cd4973c36fb75fb0d84241987febea41eee43611
17 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
18 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
19 |
20 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
21 |
22 | PKG_BUILD_PARALLEL:=1
23 |
24 | include $(INCLUDE_DIR)/package.mk
25 |
26 | define Package/tinyfecVPN
27 | SECTION:=net
28 | CATEGORY:=RA-MOD
29 | SUBMENU:=Package
30 | TITLE:=tinyfecVPN
31 | URL:=https://github.com/wangyu-/tinyfecVPN
32 | DEPENDS:=+kmod-tun +libstdcpp +librt
33 | endef
34 |
35 | define Package/tinyfecVPN/description
36 | A VPN Designed for Lossy Links, with Build-in Forward Error Correction(FEC) Support. Improves your Network Quality on a High-latency Lossy Link.
37 | endef
38 |
39 | MAKE_FLAGS += nolimit_cross
40 |
41 | define Build/Configure
42 | $(call Build/Configure/Default)
43 | $(SED) 's/cc_cross[[:space:]]*=.*/cc_cross=$(TARGET_CXX)/' \
44 | -e 's/\\".*shell git rev-parse HEAD.*\\"/\\"$(PKG_SOURCE_VERSION)\\"/' \
45 | $(PKG_BUILD_DIR)/makefile
46 | endef
47 |
48 | define Package/tinyfecVPN/install
49 | $(INSTALL_DIR) $(1)/usr/bin
50 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/tinyvpn_cross $(1)/usr/bin/tinyfecvpn
51 | endef
52 |
53 | $(eval $(call BuildPackage,tinyfecVPN))
54 |
--------------------------------------------------------------------------------
/package/udp2raw/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2014-2020 Jian Chang
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:=udp2raw
11 | PKG_VERSION:=20220126
12 | PKG_RELEASE:=1
13 |
14 | PKG_SOURCE_PROTO:=git
15 | PKG_SOURCE_URL:=https://github.com/wangyu-/udp2raw.git
16 | PKG_SOURCE_VERSION:=8ceaf27edaff70505948fbfaf8b9b864e3a11ee8
17 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
18 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
19 |
20 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
21 |
22 | PKG_BUILD_PARALLEL:=1
23 |
24 | include $(INCLUDE_DIR)/package.mk
25 |
26 | define Package/udp2raw
27 | SECTION:=net
28 | CATEGORY:=RA-MOD
29 | SUBMENU:=Package
30 | TITLE:=udp2raw
31 | URL:=https://github.com/wangyu-/udp2raw
32 | DEPENDS:=+libstdcpp +librt
33 | endef
34 |
35 | define Package/udp2raw/description
36 | A Tunnel which turns UDP Traffic into Encrypted FakeTCP/UDP/ICMP Traffic by using Raw Socket
37 | endef
38 |
39 | MAKE_FLAGS += arm_asm_aes
40 |
41 | define Build/Configure
42 | $(call Build/Configure/Default)
43 | $(SED) 's/cc_arm[[:space:]]*=.*/cc_arm=$(TARGET_CXX)/' \
44 | -e 's/\\".*shell git rev-parse HEAD.*\\"/\\"$(PKG_SOURCE_VERSION)\\"/' \
45 | $(PKG_BUILD_DIR)/makefile
46 | endef
47 |
48 | define Package/udp2raw/install
49 | $(INSTALL_DIR) $(1)/usr/bin
50 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/udp2raw_arm_asm_aes $(1)/usr/bin/udp2raw
51 | endef
52 |
53 | $(eval $(call BuildPackage,udp2raw))
--------------------------------------------------------------------------------