mirror of
https://github.com/EasyTier/luci-app-easytier.git
synced 2025-05-19 10:29:25 +00:00
@@ -0,0 +1,33 @@
|
||||
name: 编译luci-app-easytier
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: 下载工具链
|
||||
run: |
|
||||
sudo timedatectl set-timezone Asia/Shanghai
|
||||
wget -qO /opt/sdk.tar.xz https://downloads.openwrt.org/releases/22.03.5/targets/rockchip/armv8/openwrt-sdk-22.03.5-rockchip-armv8_gcc-11.2.0_musl.Linux-x86_64.tar.xz
|
||||
tar -xJf /opt/sdk.tar.xz -C /opt
|
||||
cp -R ${{ github.workspace }} /opt/luci-app-easytier
|
||||
- name: 开始编译
|
||||
run: |
|
||||
cd /opt/openwrt-sdk*/package
|
||||
cp -R /opt/luci-app-easytier .
|
||||
cd /opt/openwrt-sdk*
|
||||
./scripts/feeds update -a
|
||||
make defconfig
|
||||
cd /opt/openwrt-sdk*
|
||||
make package/luci-app-easytier/compile V=s -j1
|
||||
cd /opt/openwrt-sdk*/bin/packages/aarch64_generic/base
|
||||
ls
|
||||
mv *.ipk /opt/luci-app-easytier_all.ipk
|
||||
- name: 上传
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: luci-app-easytier
|
||||
path: /opt/luci-app-easytier_all.ipk
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# luci-app-easytier
|
||||
|
||||
依赖`kmod-tun``luci-lib-fs`需要先在系统软件包里安装好
|
||||
|
||||
### 安装方法
|
||||
```bash
|
||||
#先上传到openwrt的/tmp/tmp目录里安装
|
||||
opkg install /tmp/tmp/luci-app-easytier_all.ipk
|
||||
|
||||
#卸载
|
||||
opkg remove luci-app-easytier
|
||||
|
||||
#更新版本需要先卸载再安装新的ipk然后去管理界面关闭插件 修改参数后重新点击应用并保存
|
||||
#安装后openwrt管理界面里不显示easytier 请注销登录或关闭窗口重新打开
|
||||
```
|
||||
|
||||
此luci-app-easytier不包含二进制程序,需要自行在openwrt管理界面里的easytier插件界面里上传二进制程序
|
||||
|
||||
### 编译方法
|
||||
```bash
|
||||
#下载openwrt编译sdk到opt目录(不区分架构)
|
||||
wget -qO /opt/sdk.tar.xz https://downloads.openwrt.org/releases/22.03.5/targets/rockchip/armv8/openwrt-sdk-22.03.5-rockchip-armv8_gcc-11.2.0_musl.Linux-x86_64.tar.xz
|
||||
tar -xJf /opt/sdk.tar.xz -C /opt
|
||||
|
||||
cd /opt/openwrt-sdk*/package
|
||||
#克隆luci-app-easytier到sdk的package目录里
|
||||
git clone https://github.com/EasyTier/luci-app-easytier.git
|
||||
|
||||
cd /opt/openwrt-sdk*
|
||||
#升级脚本创建模板
|
||||
./scripts/feeds update -a
|
||||
make defconfig
|
||||
|
||||
#开始编译
|
||||
make package/luci-app-easytier/compile V=s -j1
|
||||
|
||||
#编译完成后在/opt/openwrt-sdk*/bin/packages/aarch64_generic/base目录里
|
||||
cd /opt/openwrt-sdk*/bin/packages/aarch64_generic/base
|
||||
#移动到/opt目录里
|
||||
mv *.ipk /opt/luci-app-easytier_all.ipk
|
||||
```
|
||||
@@ -3,7 +3,7 @@ local http = luci.http
|
||||
local nixio = require "nixio"
|
||||
|
||||
m = Map("easytier")
|
||||
m.description = translate('一个简单、安全、去中心化的内网穿透 VPN 组网方案,使用 Rust 语言和 Tokio 框架实现。 项目地址:<a href="https://github.com/EasyTier/EasyTier">github.com/EasyTier/EasyTier</a> <a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=jhP2Z4UsEZ8wvfGPLrs0VwLKn_uz0Q_p&authKey=OGKSQLfg61YPCpVQuvx%2BxE7hUKBVBEVi9PljrDKbHlle6xqOXx8sOwPPTncMambK&noverify=0&group_code=949700262">QQ群</a>')
|
||||
m.description = translate('一个简单、安全、去中心化的内网穿透 VPN 组网方案,使用 Rust 语言和 Tokio 框架实现。 项目地址:<a href="https://github.com/EasyTier/EasyTier">github.com/EasyTier/EasyTier</a> <a href="http://easytier.rs">官网文档</a> <a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=jhP2Z4UsEZ8wvfGPLrs0VwLKn_uz0Q_p&authKey=OGKSQLfg61YPCpVQuvx%2BxE7hUKBVBEVi9PljrDKbHlle6xqOXx8sOwPPTncMambK&noverify=0&group_code=949700262">QQ群</a>')
|
||||
|
||||
-- easytier
|
||||
m:section(SimpleSection).template = "easytier/easytier_status"
|
||||
@@ -28,54 +28,68 @@ btncq.write = function()
|
||||
end
|
||||
|
||||
network_name = s:taboption("general", Value, "network_name", translate("网络名称"),
|
||||
translate("用于识别此 VPN 网络的网络名称(这是 --network-name 参数)"))
|
||||
translate("用于识别此 VPN 网络的网络名称(--network-name 参数)"))
|
||||
network_name.password = true
|
||||
network_name.placeholder = "test"
|
||||
|
||||
network_secret = s:taboption("general", Value, "network_secret", translate("网络密钥"),
|
||||
translate("用于验证此节点是否属于 VPN 网络的网络密钥(这是 --network-secret 参数)"))
|
||||
translate("用于验证此节点是否属于 VPN 网络的网络密钥(--network-secret 参数)"))
|
||||
network_secret.password = true
|
||||
network_secret.placeholder = "test"
|
||||
|
||||
mode = s:taboption("general",ListValue, "mode", translate("接口模式"),
|
||||
translate("不指定ip地址将不会建立tun网卡,单纯作为服务器运行"))
|
||||
mode:value("不指定")
|
||||
mode:value("自动分配")
|
||||
mode:value("静态指定")
|
||||
|
||||
ip_dhcp = s:taboption("general",Flag, "ip_dhcp", translate("启用dhcp"),
|
||||
translate("由Easytier自动确定并设置IP地址,默认从10.0.0.1开始。警告:在使用DHCP时,如果网络中出现IP冲突,IP将自动更改。(-d 参数)"))
|
||||
|
||||
ipaddr = s:taboption("general",Value, "ipaddr", translate("接口IP地址"),
|
||||
translate("此 VPN 节点的 IPv4 地址,如果为空,此节点将仅转发数据包,不会创建 TUN 设备 (这是 -i 参数)"))
|
||||
ipaddr.optional = false
|
||||
translate("此VPN节点的IPv4地址,如果为空,则此节点将仅转发数据包,不会创建TUN设备(-i 参数)"))
|
||||
ipaddr.datatype = "ip4addr"
|
||||
ipaddr.placeholder = "10.0.0.1"
|
||||
ipaddr:depends("mode", "静态指定")
|
||||
|
||||
peeradd = s:taboption("general",DynamicList, "peeradd", translate("对等节点"),
|
||||
translate("初始连接的对等节点 (这是 -p 参数)"))
|
||||
translate("初始连接的对等节点 (-p 参数)"))
|
||||
peeradd.placeholder = "udp://22.1.1.1:11010"
|
||||
|
||||
external_node = s:taboption("general", Value, "external_node", translate("共享节点地址"),
|
||||
translate("使用公共共享节点来发现对等节点 (这是 -e 参数)"))
|
||||
translate("使用公共共享节点来发现对等节点 (-e 参数)"))
|
||||
external_node.placeholder = "tcp://easytier.public.kkrainbow.top:11010"
|
||||
external_node.password = true
|
||||
|
||||
proxy_network = s:taboption("general",DynamicList, "proxy_network", translate("代理网络"),
|
||||
translate("将本地网络导出到 VPN 中的其他对等点 (这是 -n 参数)"))
|
||||
translate("将本地网络导出到 VPN 中的其他对等点 (-n 参数)"))
|
||||
|
||||
rpc_portal = s:taboption("general", Value, "rpc_portal", translate("门户地址端口"),
|
||||
translate("用于管理的 RPC 门户地址。0 表示随机端口,12345 表示监听本地主机的 12345 端口,0.0.0.0:12345 表示在所有接口上监听 12345 端口。默认值为 0,首选 15888 (这是 -r 参数)"))
|
||||
translate("用于管理的 RPC 门户地址。0 表示随机端口,12345 表示监听本地主机的 12345 端口,0.0.0.0:12345 表示在所有接口上监听 12345 端口。默认值为 0,首选 15888 (-r 参数)"))
|
||||
rpc_portal.placeholder = "0"
|
||||
rpc_portal.datatype = "range(1,65535)"
|
||||
|
||||
listenermode = s:taboption("general",ListValue, "listenermode", translate("监听模式"))
|
||||
listenermode:value("OFF")
|
||||
listenermode = s:taboption("general",ListValue, "listenermode", translate("监听端口"),
|
||||
translate("OFF:不监听任何端口,只连接到对等节点 (--no-listener 参数)"))
|
||||
listenermode:value("ON")
|
||||
listenermode:value("OFF")
|
||||
|
||||
listeners = s:taboption("general",Value, "listeners", translate("监听端口"),
|
||||
translate("接受连接的监听器,只需要填端口号:11010,表示 tcp/udp 将在 11010 上监听,ws/wg 将在 11011 上监听,wss 将在 11012 上监听"))
|
||||
listeners.datatype = "range(1,65535)"
|
||||
listeners.placeholder = "11010"
|
||||
listeners:depends("listenermode", "ON")
|
||||
tcp_port = s:taboption("general",Value, "tcp_port", translate("tcp/udp端口"),
|
||||
translate("tcp/udp协议,端口号:11010,表示 tcp/udp 将在 11010 上监听"))
|
||||
tcp_port.datatype = "range(1,65535)"
|
||||
tcp_port.placeholder = "11010"
|
||||
tcp_port:depends("listenermode", "ON")
|
||||
|
||||
ws_port = s:taboption("general",Value, "ws_port", translate("ws端口"),
|
||||
translate("ws协议,端口号:11010,表示 ws 将在 11010 上监听"))
|
||||
ws_port.datatype = "range(1,65535)"
|
||||
ws_port.placeholder = "11010"
|
||||
ws_port:depends("listenermode", "ON")
|
||||
|
||||
wss_port = s:taboption("general",Value, "wss_port", translate("wss端口"),
|
||||
translate("wss协议,端口号:11011,表示 wss 将在 11011 上监听"))
|
||||
wss_port.datatype = "range(1,65535)"
|
||||
wss_port.placeholder = "11011"
|
||||
wss_port:depends("listenermode", "ON")
|
||||
|
||||
wg_port = s:taboption("general",Value, "wg_port", translate("wg端口"),
|
||||
translate("wireguard协议,端口号:11011,表示 wg 将在 11011 上监听"))
|
||||
wg_port.datatype = "range(1,65535)"
|
||||
wg_port.placeholder = "11011"
|
||||
wg_port:depends("listenermode", "ON")
|
||||
|
||||
local model = fs.readfile("/proc/device-tree/model") or ""
|
||||
local hostname = fs.readfile("/proc/sys/kernel/hostname") or ""
|
||||
@@ -84,52 +98,86 @@ hostname = hostname:gsub("\n", "")
|
||||
local device_name = (model ~= "" and model) or (hostname ~= "" and hostname) or "OpenWrt"
|
||||
device_name = device_name:gsub(" ", "_")
|
||||
desvice_name = s:taboption("general", Value, "desvice_name", translate("主机名"),
|
||||
translate("用于标识此设备的主机名 (这是 --hostname 参数)"))
|
||||
translate("用于标识此设备的主机名 (--hostname 参数)"))
|
||||
desvice_name.placeholder = device_name
|
||||
desvice_name.default = device_name
|
||||
|
||||
instance_name = s:taboption("general",Value, "instance_name", translate("实例名称"),
|
||||
translate("用于在同一台机器中标识此 VPN 节点的实例名称 (这是 --instance-name 参数)"))
|
||||
translate("用于在同一台机器中标识此 VPN 节点的实例名称 (--instance-name 参数)"))
|
||||
instance_name.placeholder = "default"
|
||||
|
||||
vpn_portal = s:taboption("general",Value, "vpn_portal", translate("VPN门户URL"),
|
||||
translate("定义 VPN 门户的 URL,允许其他 VPN 客户端连接。<br> 示例:wg://0.0.0.0:11010/10.14.14.0/24,表示 VPN 门户是一个在 vpn.example.com:11010 上监听的 WireGuard 服务器,并且 VPN 客户端位于 10.14.14.0/24 网络中(这是 --vpn-portal 参数)"))
|
||||
translate("定义 VPN 门户的 URL,允许其他 VPN 客户端连接。<br> 示例:wg://0.0.0.0:11010/10.14.14.0/24,表示 VPN 门户是一个在 vpn.example.com:11010 上监听的 WireGuard 服务器,并且 VPN 客户端位于 10.14.14.0/24 网络中(--vpn-portal 参数)"))
|
||||
vpn_portal.placeholder = "wg://0.0.0.0:11010/10.14.14.0/24"
|
||||
|
||||
mtu = s:taboption("general",Value, "mtu", translate("MTU"),
|
||||
translate("TUN 设备的 MTU,默认值为非加密时的 1420,加密时为 1400"))
|
||||
mtu.datatype = "range(1,1500)"
|
||||
mtu.placeholder = "1400"
|
||||
mtu.placeholder = "1300"
|
||||
|
||||
|
||||
default_protocol = s:taboption("general",Value, "default_protocol", translate("默认协议"),
|
||||
translate("连接对等节点时使用的默认协议(这是 --default-protocol 参数)"))
|
||||
default_protocol = s:taboption("general",ListValue, "default_protocol", translate("默认协议"),
|
||||
translate("连接对等节点时使用的默认协议(--default-protocol 参数)"))
|
||||
default_protocol:value("-")
|
||||
default_protocol:value("tcp")
|
||||
default_protocol:value("udp")
|
||||
default_protocol:value("ws")
|
||||
default_protocol:value("wss")
|
||||
default_protocol:value("wg")
|
||||
|
||||
tunname = s:taboption("general",Value, "tunname", translate("虚拟网卡名称"),
|
||||
translate("自定义虚拟网卡TUN接口的名称(--dev-name 参数)"))
|
||||
tunname.placeholder = "easytier"
|
||||
|
||||
disable_encryption = s:taboption("general",Flag, "disable_encryption", translate("禁用加密"),
|
||||
translate("禁用对等节点通信的加密,若关闭加密则其他节点也必须关闭加密 (这是 -u 参数)"))
|
||||
translate("禁用对等节点通信的加密,若关闭加密则其他节点也必须关闭加密 (-u 参数)"))
|
||||
|
||||
multi_thread = s:taboption("general",Flag, "multi_thread", translate("启用多线程"),
|
||||
translate("使用多线程运行时,默认为单线程 (这是 --multi-thread 参数)"))
|
||||
translate("使用多线程运行时,默认为单线程 (--multi-thread 参数)"))
|
||||
|
||||
disable_ipv6 = s:taboption("general",Flag, "disable_ipv6", translate("禁用ipv6"),
|
||||
translate("禁用ipv6 (这是 --disable-ipv6 参数)"))
|
||||
translate("不使用ipv6 (--disable-ipv6 参数)"))
|
||||
|
||||
latency_first = s:taboption("general",Flag, "latency_first", translate("启用延迟优先"),
|
||||
translate("优先考虑延迟? (这是 --latency-first 参数)"))
|
||||
translate("延迟优先模式,将尝试使用最低延迟路径转发流量,默认使用最短路径 (--latency-first 参数)"))
|
||||
|
||||
exit_node = s:taboption("general",Flag, "exit_node", translate("启用出口节点"),
|
||||
translate("允许此节点成为出口节点 (这是 --enable-exit-node 参数)"))
|
||||
translate("允许此节点成为出口节点 (--enable-exit-node 参数)"))
|
||||
|
||||
exit_nodes = s:taboption("general",Value, "exit_nodes", translate("出口节点地址"),
|
||||
translate("转发所有流量的出口节点,虚拟 IPv4 地址,优先级由列表顺序确定(这是 --exit-nodes 参数)"))
|
||||
exit_nodes:depends("exit_node", "1")
|
||||
exit_nodes = s:taboption("general",DynamicList, "exit_nodes", translate("出口节点地址"),
|
||||
translate("转发所有流量的出口节点,虚拟 IPv4 地址,优先级由列表顺序确定(--exit-nodes 参数)"))
|
||||
|
||||
smoltcp = s:taboption("general",Flag, "smoltcp", translate("启用smoltcp堆栈"),
|
||||
translate("为子网代理启用smoltcp堆栈(--use-smoltcp 参数)"))
|
||||
smoltcp.rmempty = false
|
||||
|
||||
no_tun = s:taboption("general",Flag, "no_tun", translate("无tun模式"),
|
||||
translate("不创建TUN设备,可以使用子网代理访问节点( --no-tun 参数)"))
|
||||
no_tun.rmempty = false
|
||||
|
||||
manual_routes = s:taboption("general",DynamicList, "manual_routes", translate("路由CIDR"),
|
||||
translate("手动分配路由CIDR,将禁用子网代理和从对等节点传播的wireguard路由。(--manual-routes 参数)"))
|
||||
manual_routes.placeholder = "192.168.0.0/16"
|
||||
|
||||
relay_network = s:taboption("general",Flag, "relay_network", translate("转发白名单网络的流量"),
|
||||
translate("仅转发白名单网络的流量,默认允许所有网络"))
|
||||
relay_network.rmempty = false
|
||||
|
||||
whitelist = s:taboption("general",DynamicList, "whitelist", translate("白名单网络"),
|
||||
translate("仅转发白名单网络的流量,输入是通配符字符串,例如:'*'(所有网络),'def*'(以def为前缀的网络)<br>可以指定多个网络。如果参数为空,则禁用转发。(--relay-network-whitelist 参数)"))
|
||||
whitelist:depends("relay_network", "1")
|
||||
|
||||
relaymode = s:taboption("general",ListValue, "relaymode", translate("P2P/转发"),
|
||||
translate("禁用P2P:禁用P2P通信,只通过-p指定的节点转发数据包 (--disable-p2p 参数)<br>允许转发P2P:转发所有对等节点的RPC数据包,即使对等节点不在转发网络白名单中。这可以帮助白名单外网络中的对等节点建立P2P连接。 (--relay-all-peer-rpc 参数)"))
|
||||
relaymode:value("-", translate("默认"))
|
||||
relaymode:value("disable_p2p", translate("禁用P2P"))
|
||||
relaymode:value("relay_all", translate("允许转发P2P"))
|
||||
|
||||
log = s:taboption("general",Flag, "log", translate("启用日志"),
|
||||
translate("运行日志在/tmp/easytier.log,可在上方日志查看"))
|
||||
log.rmempty = false
|
||||
|
||||
check = s:taboption("general",Flag, "check", translate("通断检测"),
|
||||
translate("开启通断检测后,可以指定对端的设备IP,当所有指定的IP都ping不通时将会重启vnt程序"))
|
||||
translate("开启通断检测后,可以指定对端的设备IP,当所有指定的IP都ping不通时将会重启easytier程序"))
|
||||
|
||||
checkip=s:taboption("general",DynamicList,"checkip",translate("检测IP"),
|
||||
translate("确保这里的对端设备IP地址填写正确且可访问,若填写错误将会导致无法ping通,程序反复重启"))
|
||||
@@ -327,6 +375,9 @@ http.setfilehandler(
|
||||
if string.sub(meta.file, -4) == ".zip" then
|
||||
local file_path = dir .. meta.file
|
||||
os.execute("unzip -q " .. file_path .. " -d " .. dir)
|
||||
local extracted_dir = "/tmp/easytier-linux-*/"
|
||||
os.execute("mv " .. extracted_dir .. "easytier-cli /tmp/easytier-cli")
|
||||
os.execute("mv " .. extracted_dir .. "easytier-core /tmp/easytier-core")
|
||||
if nixio.fs.access("/tmp/easytier-cli") then
|
||||
um.value = um.value .. "\n" .. translate("-程序/tmp/easytier-cli上传成功,重启一次插件才生效")
|
||||
end
|
||||
@@ -334,8 +385,8 @@ http.setfilehandler(
|
||||
um.value = um.value .. "\n" .. translate("-程序/tmp/easytier-core上传成功,重启一次插件才生效")
|
||||
end
|
||||
end
|
||||
os.execute("chmod a+x /tmp/easytier-core")
|
||||
os.execute("chmod a+x /tmp/easytier-cli")
|
||||
os.execute("chmod +x /tmp/easytier-core")
|
||||
os.execute("chmod +x /tmp/easytier-cli")
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
+120
-50
@@ -53,7 +53,7 @@ start_et() {
|
||||
[ "$enabled" = "1" ] || return 1
|
||||
config_get easytierbin "$cfg" 'easytierbin' '/tmp/easytier-core'
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : easytier-core_${cpucore}开始启动" >>/tmp/easytier.log
|
||||
#test -z "`opkg list-installed|grep kmod-tun`" && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 缺少kmod-tun插件" >>/tmp/easytier.log
|
||||
test -z "`opkg list-installed|grep kmod-tun`" && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 缺少kmod-tun插件" >>/tmp/easytier.log
|
||||
path=$(dirname "$easytierbin")
|
||||
if [ -f /tmp/easytier-core ] || [ -f /tmp/easytier-cli ] && [ "${path:0:4}" != "/tmp" ] ;then
|
||||
chmod +x /tmp/easytier-core 2>/dev/null
|
||||
@@ -61,7 +61,7 @@ start_et() {
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 找到上传的程序/tmp/easytier-core,替换为$easytierbin " >>/tmp/easytier.log
|
||||
upsize="$(du -k /tmp/easytier-core | cut -f1)"
|
||||
result=$(expr $size - $upsize)
|
||||
if [ $(($(/tmp/easytier-core -h | wc -l))) -gt 3 ] && [ "$result" -gt 2000 ] ; then
|
||||
if [ $(($(/tmp/easytier-core -h | wc -l))) -gt 3 ] && [ "$result" -gt 4000 ] ; then
|
||||
mv -f /tmp/easytier-core "$easytierbin" 2>/dev/null
|
||||
mv -f /tmp/easytier-cli "${path}/easytier-cli" 2>/dev/null
|
||||
else
|
||||
@@ -75,50 +75,66 @@ start_et() {
|
||||
fi
|
||||
if [ $(($($easytierbin -h | wc -l))) -lt 3 ] || [ ! -f "$easytierbin" ] ; then
|
||||
newtag="$( curl --connect-timeout 3 --user-agent 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' https://api.github.com/repos/EasyTier/EasyTier/releases/latest 2>&1 | grep 'tag_name' | cut -d\" -f4 )"
|
||||
[ -z "$newtag"] && newtag=v1.1.0
|
||||
[ -z "$newtag"] && newtag="$( wget -T 5 -t 3 --user-agent 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' --quiet --output-document=- https://api.github.com/repos/EasyTier/EasyTier/releases/latest 2>&1 | grep 'tag_name' | cut -d\" -f4 )"
|
||||
[ -z "$newtag"] && newtag=v1.2.1
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 未找到程序 $easytierbin 开始在线下载${newtag},下载较慢耐心等候" >>/tmp/easytier.log
|
||||
mkdir -p "$path"
|
||||
curl -L -k -s -o /tmp/easytier.zip --connect-timeout 10 --retry 3 "http://gh.ddlc.top/https://github.com/EasyTier/EasyTier/releases/download/${newtag}/easytier-${core_url}-${newtag}.zip" || curl -L -k -s -o /tmp/easytier.zip --connect-timeout 10 --retry 3 "https://hub.gitmirror.com/https://github.com/EasyTier/EasyTier/releases/download/${newtag}/easytier-${core_url}-${newtag}.zip" || curl -L -k -s -o /tmp/easytier.zip --connect-timeout 10 --retry 3 "https://github.com/EasyTier/EasyTier/releases/download/${newtag}/easytier-${core_url}-${newtag}.zip"
|
||||
unzip -q -o /tmp/easytier.zip -d $path
|
||||
curl -L -k -s -o /tmp/easytier.zip --connect-timeout 10 --retry 3 "http://gh.ddlc.top/https://github.com/EasyTier/EasyTier/releases/download/${newtag}/easytier-linux-${cpucore}-${newtag}.zip" || curl -L -k -s -o /tmp/easytier.zip --connect-timeout 10 --retry 3 "https://hub.gitmirror.com/https://github.com/EasyTier/EasyTier/releases/download/${newtag}/easytier-linux-${cpucore}-${newtag}.zip" || curl -L -k -s -o /tmp/easytier.zip --connect-timeout 10 --retry 3 "https://github.com/EasyTier/EasyTier/releases/download/${newtag}/easytier-linux-${cpucore}-${newtag}.zip"
|
||||
unzip -q -o /tmp/easytier.zip -d /tmp
|
||||
chmod +x /tmp/easytier-linux-${cpucore}-${newtag}/*
|
||||
mv -f /tmp/easytier-linux-${cpucore}-${newtag}/* ${path}/*
|
||||
chmod +x "$easytierbin"
|
||||
rm -rf /tmp/easytier.zip
|
||||
if [ $(($($easytierbin -h | wc -l))) -gt 3 ]; then
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : ${easytierbin} 下载成功" >>/tmp/easytier.log
|
||||
else
|
||||
uci -q set easytier.@easytier[0].enabled=0
|
||||
uci commit easytier
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : $easytierbin 下载失败,请手动下载上传程序,程序退出" >>/tmp/easytier.log
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : https://github.com/EasyTier/EasyTier/releases/download/${newtag}/easytier-linux-${cpucore}-${newtag}.zip 下载失败,请手动下载上传程序,程序退出" >>/tmp/easytier.log
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
chmod +x "$easytierbin"
|
||||
chmod +x "$easytierbin"
|
||||
chmod +x ${path}/easytier-cli
|
||||
ver="$($easytierbin -h | grep version | awk -F ':' {'print $2'})"
|
||||
[ ! -z "$ver" ] && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : ${easytierbin}当前版本号-${ver} " >>/tmp/easytier.log
|
||||
killall easytier_check >/dev/null 2>&1
|
||||
killall easytier-core >/dev/null 2>&1
|
||||
killall -9 easytier-core >/dev/null 2>&1
|
||||
local network_name network_secret mode ipaddr peeradd external_node rpc_portal listenermode
|
||||
local listeners desvice_name instance_name vpn_portal mtu default_protocol disable_encryption
|
||||
local multi_thread disable_ipv6 latency_first exit_node exit_nodes log check checkip proxy_network
|
||||
pgrep -f easytier_check | xargs kill -9 >/dev/null 2>&1
|
||||
ps | grep 'easytier-core' | grep -v grep | awk '{print $1}' | xargs kill >/dev/null 2>&1
|
||||
ps | grep 'easytier-core' | grep -v grep | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
|
||||
local network_name network_secret ip_dhcp ipaddr peeradd external_node rpc_portal listenermode tunname relay_network relaymode
|
||||
local tcp_port ws_port wss_port wg_port desvice_name instance_name vpn_portal mtu default_protocol disable_encryption whitelist
|
||||
local multi_thread disable_ipv6 latency_first exit_node exit_nodes smoltcp no_tun manual_routes log check checkip proxy_network
|
||||
config_get network_name "$cfg" 'network_name'
|
||||
config_get network_secret "$cfg" 'network_secret'
|
||||
config_get mode "$cfg" 'mode'
|
||||
config_get_bool ip_dhcp "$cfg" 'ip_dhcp' '0'
|
||||
config_get ipaddr "$cfg" 'ipaddr'
|
||||
config_get external_node "$cfg" 'external_node'
|
||||
config_get proxy_network "$cfg" 'proxy_network'
|
||||
config_get rpc_portal "$cfg" 'rpc_portal'
|
||||
config_get listenermode "$cfg" 'listenermode'
|
||||
config_get listeners "$cfg" 'listeners'
|
||||
config_get tunname "$cfg" 'tunname'
|
||||
config_get_bool relay_network "$cfg" 'relay_network' '0'
|
||||
config_get tcp_port "$cfg" 'tcp_port'
|
||||
config_get ws_port "$cfg" 'ws_port'
|
||||
config_get wss_port "$cfg" 'wss_port'
|
||||
config_get wg_port "$cfg" 'wg_port'
|
||||
config_get peeradd "$cfg" 'peeradd'
|
||||
config_get desvice_name "$cfg" 'desvice_name'
|
||||
config_get instance_name "$cfg" 'instance_name'
|
||||
config_get vpn_portal "$cfg" 'vpn_portal'
|
||||
config_get mtu "$cfg" 'mtu' '1400'
|
||||
config_get mtu "$cfg" 'mtu'
|
||||
config_get default_protocol "$cfg" 'default_protocol'
|
||||
config_get_bool disable_encryption "$cfg" 'disable_encryption' '0'
|
||||
config_get whitelist "$cfg" 'whitelist'
|
||||
config_get_bool multi_thread "$cfg" 'multi_thread' '0'
|
||||
config_get_bool disable_ipv6 "$cfg" 'disable_ipv6' '0'
|
||||
config_get_bool latency_first "$cfg" 'latency_first' '0'
|
||||
config_get_bool exit_node "$cfg" 'exit_node' '0'
|
||||
config_get_bool smoltcp "$cfg" 'smoltcp' '0'
|
||||
config_get exit_nodes "$cfg" 'exit_nodes'
|
||||
config_get_bool no_tun "$cfg" 'no_tun' '0'
|
||||
config_get manual_routes "$cfg" 'manual_routes'
|
||||
config_get relaymode "$cfg" 'relaymode'
|
||||
config_get_bool log "$cfg" 'log' '0'
|
||||
config_get_bool check "$cfg" 'check' '0'
|
||||
config_get checkip "$cfg" 'checkip'
|
||||
@@ -127,8 +143,8 @@ start_et() {
|
||||
procd_set_param command "$easytierbin"
|
||||
[ -z "$network_name" ] || procd_append_param command --network-name "$network_name"
|
||||
[ -z "$network_secret" ] || procd_append_param command --network-secret "$network_secret"
|
||||
[ "$mode" = "静态指定" ] && [ ! -z "$ipaddr" ] && procd_append_param command -i "$ipaddr"
|
||||
[ "$mode" = "自动分配" ] && procd_append_param command -d
|
||||
[ -z "$ipaddr" ] || procd_append_param command -i "$ipaddr"
|
||||
[ "$ip_dhcp" = "0" ] || procd_append_param command -d
|
||||
if [ ! -z "$peeradd" ] ; then
|
||||
if [[ "$(grep "list peeradd" /etc/config/easytier | awk '{print $3}' | wc -l ) " -eq 1 ]]; then
|
||||
procd_append_param command -p "$peeradd"
|
||||
@@ -147,24 +163,59 @@ start_et() {
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [ ! -z "$exit_nodes" ] ; then
|
||||
if [[ "$(grep "list exit_nodes" /etc/config/easytier | awk '{print $3}' | wc -l ) " -eq 1 ]]; then
|
||||
procd_append_param command --exit-nodes "$exit_nodes"
|
||||
else
|
||||
for exit_nodeadds in $(cat /etc/config/easytier | grep 'list exit_nodes' | awk -F 'list exit_nodes' '{print $2}' | sed "s/'/\n/g" | tr -d " ' "); do
|
||||
procd_append_param command --exit-nodes "$exit_nodeadds"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [ ! -z "$manual_routes" ] ; then
|
||||
if [[ "$(grep "list manual_routes" /etc/config/easytier | awk '{print $3}' | wc -l ) " -eq 1 ]]; then
|
||||
procd_append_param command --manual-routes "$manual_routes"
|
||||
else
|
||||
for manual_routeadds in $(cat /etc/config/easytier | grep 'list manual_routes' | awk -F 'list manual_routes' '{print $2}' | sed "s/'/\n/g" | tr -d " ' "); do
|
||||
procd_append_param command --manual-routes "$manual_routeadds"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [ ! -z "$whitelist" ] ; then
|
||||
if [[ "$(grep "list whitelist" /etc/config/easytier | awk '{print $3}' | wc -l ) " -eq 1 ]]; then
|
||||
procd_append_param command --relay-network-whitelist "$whitelist"
|
||||
else
|
||||
for whitelists in $(cat /etc/config/easytier | grep 'list whitelist' | awk -F 'list whitelist' '{print $2}' | sed "s/'/\n/g" | tr -d " ' "); do
|
||||
procd_append_param command --relay-network-whitelist "$whitelists"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
[ -z "$external_node" ] || procd_append_param command -e "$external_node"
|
||||
[ -z "$rpc_portal" ] || procd_append_param command -r "$rpc_portal"
|
||||
[ "$listenermode" = "ON" ] && [ ! -z "$listeners" ] && procd_append_param command -l "$listeners"
|
||||
[ "$listenermode" = "OFF" ] && procd_append_param command --no-listener
|
||||
[ -z "$tcp_port" ] || procd_append_param command -l "tcp:$tcp_port"
|
||||
[ -z "$tcp_port" ] || procd_append_param command -l "udp:$tcp_port"
|
||||
[ -z "$ws_port" ] || procd_append_param command -l "ws:$ws_port"
|
||||
[ -z "$wss_port" ] || procd_append_param command -l "wss:$wss_port"
|
||||
[ -z "$wg_port" ] || procd_append_param command -l "wg:$wg_port"
|
||||
[ "$listenermode" = "ON" ] || procd_append_param command --no-listener
|
||||
[ -z "$desvice_name" ] || procd_append_param command --hostname "$desvice_name"
|
||||
[ -z "$instance_name" ] || procd_append_param command -m "$instance_name"
|
||||
[ -z "$vpn_portal" ] || procd_append_param command --vpn-portal "$vpn_portal"
|
||||
[ -z "$mtu" ] || procd_append_param command --mtu "$mtu"
|
||||
[ -z "$default_protocol" ] || procd_append_param command --default-protocol "$default_protocol"
|
||||
[ "$default_protocol" = "-" ] || procd_append_param command --default-protocol "$default_protocol"
|
||||
[ -z "$tunname" ] || procd_append_param command --dev-name "$tunname"
|
||||
[ "$disable_encryption" = "0" ] || procd_append_param command -u
|
||||
[ "$multi_thread" = "0" ] || procd_append_param command --multi-thread
|
||||
[ "$no_tun" = "0" ] || procd_append_param command --no-tun
|
||||
[ "$smoltcp" = "0" ] || procd_append_param command --use-smoltcp
|
||||
[ "$disable_ipv6" = "0" ] || procd_append_param command --disable-ipv6
|
||||
[ "$latency_first" = "0" ] || procd_append_param command --latency-first
|
||||
[ "$exit_node" = "0" ] || procd_append_param command --enable-exit-node
|
||||
[ -z "$exit_nodes" ] || procd_append_param command --exit-nodes "$exit_nodes"
|
||||
[ "$log" = "1" ] && procd_append_param command --file-log-level "info"
|
||||
[ "$log" = "1" ] && procd_append_param command --file-log-dir "/tmp"
|
||||
[ "$log" = "0" ] && procd_append_param command --file-log-level "off"
|
||||
[ "$relaymode" = "disable_p2p" ] && procd_append_param command --disable-p2p
|
||||
[ "$relaymode" = "relay_all" ] && procd_append_param command --relay-all-peer-rpc
|
||||
[ ! -z "$instance_name" ] && ln -sf /tmp/easytier-${instance_name}.${date_time} /tmp/easytier.log
|
||||
|
||||
procd_set_param limits core="unlimited"
|
||||
@@ -173,20 +224,18 @@ start_et() {
|
||||
procd_set_param stderr 1
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
|
||||
if [ ! -z "$listeners" ] ; then
|
||||
tcpudp_port="$listeners"
|
||||
wgws_port=$((tcpudp_port + 1))
|
||||
wss_port=$((tcpudp_port + 2))
|
||||
|
||||
uci -q delete firewall.easytier_tcp_udp
|
||||
if [ "$listenermode" = "ON" ] ; then
|
||||
[ -z "$tcp_port" ] && tcp_port="11010"
|
||||
[ -z "$ws_port" ] && ws_port="11011"
|
||||
[ -z "$wss_port" ] && wss_port="11012"
|
||||
[ -z "$wg_port" ] && wg_port="11011"
|
||||
uci -q delete firewall.easytier_tcp_udp
|
||||
uci set firewall.easytier_tcp_udp=rule
|
||||
uci set firewall.easytier_tcp_udp.name="easytier_tcp_udp"
|
||||
uci set firewall.easytier_tcp_udp.target="ACCEPT"
|
||||
uci set firewall.easytier_tcp_udp.src="wan"
|
||||
uci set firewall.easytier_tcp_udp.proto="all"
|
||||
uci set firewall.easytier_tcp_udp.dest_port="$tcpudp_port"
|
||||
uci set firewall.easytier_tcp_udp.dest_port="$tcp_port"
|
||||
uci set firewall.easytier_tcp_udp.enabled="1"
|
||||
|
||||
uci -q delete firewall.easytier_wss
|
||||
@@ -197,21 +246,40 @@ start_et() {
|
||||
uci set firewall.easytier_wss.proto="all"
|
||||
uci set firewall.easytier_wss.dest_port="$wss_port"
|
||||
uci set firewall.easytier_wss.enabled="1"
|
||||
|
||||
if [ "$ws_port" = "$wg_port" ] ; then
|
||||
uci -q delete firewall.easytier_wg_ws
|
||||
uci set firewall.easytier_wg_ws=rule
|
||||
uci set firewall.easytier_wg_ws.name="easytier_wg_ws"
|
||||
uci set firewall.easytier_wg_ws.target="ACCEPT"
|
||||
uci set firewall.easytier_wg_ws.src="wan"
|
||||
uci set firewall.easytier_wg_ws.proto="all"
|
||||
uci set firewall.easytier_wg_ws.dest_port="$wgws_port"
|
||||
uci set firewall.easytier_wg_ws.dest_port="$ws_port"
|
||||
uci set firewall.easytier_wg_ws.enabled="1"
|
||||
fi
|
||||
|
||||
else
|
||||
uci -q delete firewall.easytier_ws
|
||||
uci set firewall.easytier_ws=rule
|
||||
uci set firewall.easytier_ws.name="easytier_ws"
|
||||
uci set firewall.easytier_ws.target="ACCEPT"
|
||||
uci set firewall.easytier_ws.src="wan"
|
||||
uci set firewall.easytier_ws.proto="all"
|
||||
uci set firewall.easytier_ws.dest_port="$ws_port"
|
||||
uci set firewall.easytier_ws.enabled="1"
|
||||
|
||||
uci -q delete firewall.easytier_wg
|
||||
uci set firewall.easytier_wg=rule
|
||||
uci set firewall.easytier_wg.name="easytier_wg"
|
||||
uci set firewall.easytier_wg.target="ACCEPT"
|
||||
uci set firewall.easytier_wg.src="wan"
|
||||
uci set firewall.easytier_wg.proto="all"
|
||||
uci set firewall.easytier_wg.dest_port="$wg_port"
|
||||
uci set firewall.easytier_wg.enabled="1"
|
||||
fi
|
||||
fi
|
||||
[ -z "$tunname" ] && tunname="tun0"
|
||||
if [ -z "$(uci -q get network.EasyTier)" ]; then
|
||||
uci set network.EasyTier='interface'
|
||||
uci set network.EasyTier.device=tun0
|
||||
uci set network.EasyTier.ifname=tun0
|
||||
uci set network.EasyTier.device="$tunname"
|
||||
uci set network.EasyTier.ifname="$tunname"
|
||||
fi
|
||||
if [ -z "$(uci -q get firewall.easytierzone)" ]; then
|
||||
uci set firewall.easytierzone='zone'
|
||||
@@ -258,26 +326,26 @@ start_service() {
|
||||
ln -sf /tmp/easytier-default.${date_time} /tmp/easytier.log
|
||||
fi
|
||||
cputype=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]')
|
||||
[ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="arm" ; core_url="arm-unknown-linux-musleabi"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && [ ! -d /jffs/clash ] && cpucore="armv7" ; core_url="armv7-unknown-linux-musleabi"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="aarch64" ; core_url="aarch64-unknown-linux-musl"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="i386" ; core_url=""
|
||||
[ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="x86_64" ; core_url="x86_64-unknown-linux-musl"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="arm"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && [ ! -d /jffs/clash ] && cpucore="armv7"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="aarch64"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="i386"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="x86_64"
|
||||
if [ -n "$(echo $cputype | grep -E "linux.*mips.*")" ] ; then
|
||||
mipstype=$(echo -n I | hexdump -o 2>/dev/null | awk '{ print substr($2,6,1); exit}')
|
||||
[ "$mipstype" = "0" ] && cpucore="mips" ; core_url="mips-unknown-linux-musl" || cpucore="mipsle" ; core_url="mipsel-unknown-linux-musl"
|
||||
[ "$mipstype" = "0" ] && cpucore="mips" || cpucore="mipsle"
|
||||
fi
|
||||
|
||||
#test -z "`opkg list-installed|grep curl`" && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 缺少curl插件" >>/tmp/easytier.log
|
||||
#test -z "`opkg list-installed|grep luci-lib-fs`" && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 缺少luci-lib-fs插件" >>/tmp/easytier.log
|
||||
#test -z "`opkg list-installed|grep unzip`" && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 缺少unzip插件" >>/tmp/easytier.log
|
||||
test -z "`opkg list-installed|grep curl`" && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 缺少curl插件" >>/tmp/easytier.log
|
||||
test -z "`opkg list-installed|grep luci-lib-fs`" && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 缺少luci-lib-fs插件" >>/tmp/easytier.log
|
||||
test -z "`opkg list-installed|grep unzip`" && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 缺少unzip插件" >>/tmp/easytier.log
|
||||
config_foreach start_et 'easytier'
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
killall easytier_check >/dev/null 2>&1
|
||||
killall easytier-core >/dev/null 2>&1
|
||||
killall -9 easytier-core >/dev/null 2>&1
|
||||
pgrep -f easytier_check | xargs kill -9 >/dev/null 2>&1
|
||||
ps | grep 'easytier-core' | grep -v grep | awk '{print $1}' | xargs kill >/dev/null 2>&1
|
||||
ps | grep 'easytier-core' | grep -v grep | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
|
||||
uci -q delete network.EasyTier >/dev/null 2>&1
|
||||
uci -q delete firewall.easytierzone >/dev/null 2>&1
|
||||
uci -q delete firewall.easytierfwlan >/dev/null 2>&1
|
||||
@@ -286,7 +354,9 @@ stop_service() {
|
||||
uci -q delete firewall.wanfweasytier >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_tcp_udp >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_wg_ws >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_wg_wss >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_wss >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_ws >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_wg >/dev/null 2>&1
|
||||
[ -n "$(uci changes network)" ] && uci commit network && /etc/init.d/network reload >/dev/null 2>&1
|
||||
[ -n "$(uci changes firewall)" ] && uci commit firewall && /etc/init.d/firewall reload >/dev/null 2>&1
|
||||
rm -rf /tmp/easytier-cli_peer /tmp/easytier-cli_connector /tmp/easytier-cli_stun /tmp/easytier-cli_route >/dev/null 2>&1
|
||||
|
||||
@@ -6,6 +6,6 @@ uci -q batch <<-EOF >/dev/null
|
||||
set ucitrack.@easytier[-1].init=easytier
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
chmod +x /etc/init.d/easytier
|
||||
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user