mirror of
https://github.com/kenzok8/small-package
synced 2025-01-05 11:36:47 +08:00
update 2024-12-25 19:37:30
This commit is contained in:
parent
7dbd5ff2be
commit
bfb9541876
49
luci-app-easytier/Makefile
Normal file
49
luci-app-easytier/Makefile
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_VERSION:=2.0.3
|
||||
PKG_RELEASE:=
|
||||
|
||||
LUCI_TITLE:=LuCI support for EasyTier
|
||||
LUCI_DEPENDS:=
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_NAME:=luci-app-easytier
|
||||
|
||||
define Package/$(PKG_NAME)/prerm
|
||||
#!/bin/sh
|
||||
if [ -f /etc/config/easytier ] ; then
|
||||
echo "备份easytier配置文件/etc/config/easytier到/tmp/easytier_backup"
|
||||
echo "不重启设备之前再次安装luci-app-easytier 配置不丢失,不用重新配置"
|
||||
mv -f /etc/config/easytier /tmp/easytier_backup
|
||||
fi
|
||||
if [ -f /etc/easytier/config.toml ] ; then
|
||||
echo "备份easytier配置文件/etc/easytier/config.toml到/tmp/config_backup.toml"
|
||||
echo "不重启设备之前再次安装luci-app-easytier 配置不丢失,不用重新配置"
|
||||
mv -f /etc/easytier/config.toml /tmp/config_backup.toml
|
||||
fi
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
chmod +x /etc/init.d/easytier
|
||||
if [ -f /tmp/easytier_backup ] ; then
|
||||
echo "发现easytier备份配置文件/tmp/easytier_backup,开始恢复到/etc/config/easytier"
|
||||
mv -f /tmp/easytier_backup /etc/config/easytier
|
||||
echo "请前往 VPN - EasyTier 界面进行重启插件"
|
||||
fi
|
||||
if [ -f /tmp/config_backup.toml ] ; then
|
||||
echo "发现easytier备份配置文件/tmp/config_backup.toml,开始恢复到/etc/easytier/config.toml"
|
||||
mv -f /tmp/config_backup.toml /etc/easytier/config.toml
|
||||
echo "请前往 VPN - EasyTier 界面进行重启插件"
|
||||
fi
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
46
luci-app-easytier/README.md
Normal file
46
luci-app-easytier/README.md
Normal file
@ -0,0 +1,46 @@
|
||||
# luci-app-easytier
|
||||
|
||||
依赖`kmod-tun`需要先在系统软件包里安装好
|
||||
### 快速开始
|
||||
```bash
|
||||
右上角Fork克隆本项目,去actions手动触发自动编译流程,2分钟后就能获取最新ipk压缩包`luci-app-easytier.zip`解压上传到Openwrt软路由安装即可
|
||||
|
||||
```
|
||||
![actions界面](https://github.com/user-attachments/assets/7e5e843b-eb01-48f1-81ab-226a1418ca0f)
|
||||
### 安装方法
|
||||
```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
|
||||
```
|
69
luci-app-easytier/luasrc/controller/easytier.lua
Normal file
69
luci-app-easytier/luasrc/controller/easytier.lua
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
module("luci.controller.easytier", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/easytier") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "vpn", "easytier"}, alias("admin", "vpn", "easytier", "easytier"),_("EasyTier"), 46).dependent = true
|
||||
entry({"admin", "vpn", "easytier", "easytier"}, cbi("easytier"),_("EasyTier"), 47).leaf = true
|
||||
entry({"admin", "vpn", "easytier", "easytier_log"}, form("easytier_log"),_("日志"), 48).leaf = true
|
||||
entry({"admin", "vpn", "easytier", "get_log"}, call("get_log")).leaf = true
|
||||
entry({"admin", "vpn", "easytier", "clear_log"}, call("clear_log")).leaf = true
|
||||
entry({"admin", "vpn", "easytier", "status"}, call("act_status")).leaf = true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e = {}
|
||||
local sys = require "luci.sys"
|
||||
e.crunning = luci.sys.call("pgrep easytier-core >/dev/null") == 0
|
||||
local tagfile = io.open("/tmp/easytier_time", "r")
|
||||
if tagfile then
|
||||
local tagcontent = tagfile:read("*all")
|
||||
tagfile:close()
|
||||
if tagcontent and tagcontent ~= "" then
|
||||
os.execute("start_time=$(cat /tmp/easytier_time) && time=$(($(date +%s)-start_time)) && day=$((time/86400)) && [ $day -eq 0 ] && day='' || day=${day}天 && time=$(date -u -d @${time} +'%H小时%M分%S秒') && echo $day $time > /tmp/command_easytier 2>&1")
|
||||
local command_output_file = io.open("/tmp/command_easytier", "r")
|
||||
if command_output_file then
|
||||
e.etsta = command_output_file:read("*all")
|
||||
command_output_file:close()
|
||||
end
|
||||
end
|
||||
end
|
||||
local command2 = io.popen('test ! -z "`pidof easytier-core`" && (top -b -n1 | grep -E "$(pidof easytier-core)" 2>/dev/null | grep -v grep | awk \'{for (i=1;i<=NF;i++) {if ($i ~ /easytier-core/) break; else cpu=i}} END {print $cpu}\')')
|
||||
e.etcpu = command2:read("*all")
|
||||
command2:close()
|
||||
local command3 = io.popen("test ! -z `pidof easytier-core` && (cat /proc/$(pidof easytier-core | awk '{print $NF}')/status | grep -w VmRSS | awk '{printf \"%.2f MB\", $2/1024}')")
|
||||
e.etram = command3:read("*all")
|
||||
command3:close()
|
||||
|
||||
local command8 = io.popen("([ -s /tmp/easytiernew.tag ] && cat /tmp/easytiernew.tag ) || ( curl -L -k -s --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 | grep tag_name | sed 's/[^0-9.]*//g' >/tmp/easytiernew.tag && cat /tmp/easytiernew.tag )")
|
||||
e.etnewtag = command8:read("*all")
|
||||
command8:close()
|
||||
local command9 = io.popen("([ -s /tmp/easytier.tag ] && cat /tmp/easytier.tag ) || ( echo `$(uci -q get easytier.@easytier[0].easytierbin) -V | sed 's/^[^0-9]*//'` > /tmp/easytier.tag && cat /tmp/easytier.tag && [ ! -s /tmp/easytier.tag ] && echo '?' >> /tmp/easytier.tag && cat /tmp/easytier.tag )")
|
||||
e.ettag = command9:read("*all")
|
||||
command9:close()
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function get_log()
|
||||
local log = ""
|
||||
local files = {"/tmp/easytier.log"}
|
||||
for i, file in ipairs(files) do
|
||||
if luci.sys.call("[ -f '" .. file .. "' ]") == 0 then
|
||||
log = log .. luci.sys.exec("cat " .. file)
|
||||
end
|
||||
end
|
||||
luci.http.write(log)
|
||||
end
|
||||
|
||||
function clear_log()
|
||||
luci.sys.call("echo '' >/tmp/easytier.log")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
497
luci-app-easytier/luasrc/model/cbi/easytier.lua
Normal file
497
luci-app-easytier/luasrc/model/cbi/easytier.lua
Normal file
@ -0,0 +1,497 @@
|
||||
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://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> <a href="https://doc.oee.icu">菜鸟教程</a>')
|
||||
|
||||
-- easytier
|
||||
m:section(SimpleSection).template = "easytier/easytier_status"
|
||||
|
||||
s=m:section(TypedSection, "easytier", translate("EasyTier配置"))
|
||||
s.addremove=false
|
||||
s.anonymous=true
|
||||
s:tab("general", translate("基本设置"))
|
||||
s:tab("privacy", translate("高级设置"))
|
||||
s:tab("infos", translate("连接信息"))
|
||||
s:tab("upload", translate("上传程序"))
|
||||
|
||||
switch = s:taboption("general",Flag, "enabled", translate("Enable"))
|
||||
switch.rmempty = false
|
||||
|
||||
btncq = s:taboption("general", Button, "btncq", translate("重启"))
|
||||
btncq.inputtitle = translate("重启")
|
||||
btncq.description = translate("在没有修改参数的情况下快速重新启动一次")
|
||||
btncq.inputstyle = "apply"
|
||||
btncq:depends("enabled", "1")
|
||||
btncq.write = function()
|
||||
os.execute("/etc/init.d/easytier restart &")
|
||||
end
|
||||
|
||||
etcmd = s:taboption("privacy",ListValue, "etcmd", translate("启动方式"),
|
||||
translate("默认使用命令行方式启动,也可以使用配置文件启动<br>切换启动方式后将以指定的方式启动,请谨慎选择"))
|
||||
etcmd.default = "etcmd"
|
||||
etcmd:value("etcmd",translate("命令行"))
|
||||
etcmd:value("config",translate("配置文件"))
|
||||
|
||||
et_config = s:taboption("privacy",TextValue, "et_config", translate("配置文件"),
|
||||
translate("配置文件在/etc/easytier/config.toml<br>命令行的启动参数和此配置文件的参数并不同步,请自行修改<br>配置文件介绍:<a href='https://easytier.rs/guide/network/config-file.html'>点此查看</a>"))
|
||||
et_config.rows = 18
|
||||
et_config.wrap = "off"
|
||||
et_config:depends("etcmd", "config")
|
||||
|
||||
et_config.cfgvalue = function(self, section)
|
||||
return nixio.fs.readfile("/etc/easytier/config.toml") or ""
|
||||
end
|
||||
et_config.write = function(self, section, value)
|
||||
local dir = "/etc/easytier/"
|
||||
local file = dir .. "config.toml"
|
||||
-- 检查目录是否存在,如果不存在则创建
|
||||
if not nixio.fs.access(dir) then
|
||||
nixio.fs.mkdir(dir)
|
||||
end
|
||||
nixio.fs.writefile(file, value:gsub("\r\n", "\n"))
|
||||
end
|
||||
|
||||
network_name = s:taboption("general", Value, "network_name", translate("网络名称"),
|
||||
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 参数)"))
|
||||
network_secret.password = true
|
||||
network_secret.placeholder = "test"
|
||||
|
||||
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.datatype = "ip4addr"
|
||||
ipaddr.placeholder = "10.0.0.1"
|
||||
|
||||
peeradd = s:taboption("general",DynamicList, "peeradd", translate("对等节点"),
|
||||
translate("初始连接的对等节点,和下方参数作用一样 (-p 参数)<br>公共服务器可用状态查询:<a href='https://easytier.gd.nkbpal.cn/status/easytier' target='_blank'>点此查询</a>"))
|
||||
peeradd.placeholder = "tcp://public.easytier.top:11010"
|
||||
peeradd:value("tcp://public.easytier.top:11010", translate("官方公共服务器-广东河源-tcp://public.easytier.top:11010"))
|
||||
peeradd:value("tcp://43.136.45.249:11010", translate("广州V4-tcp://43.136.45.249:11010"))
|
||||
peeradd:value("tcp://et.ie12vps.xyz:11010", translate("南京V4/V6-tcp://et.ie12vps.xyz:11010"))
|
||||
peeradd:value("tcp://minebg.top:11010", translate("广州V4-tcp://minebg.top:11010"))
|
||||
peeradd:value("tcp://ah.nkbpal.cn:11010", translate("安徽电信V4-tcp://ah.nkbpal.cn:11010"))
|
||||
peeradd:value("udp://ah.nkbpal.cn:11010", translate("安徽电信V4-udp://ah.nkbpal.cn:11010"))
|
||||
peeradd:value("wss://ah.nkbpal.cn:11012", translate("安徽电信V4-wss://ah.nkbpal.cn:11012"))
|
||||
peeradd:value("tcp://222.186.59.80:11113", translate("江苏镇江V4-tcp://222.186.59.80:11113"))
|
||||
peeradd:value("wss://222.186.59.80:11115", translate("江苏镇江V4-wss://222.186.59.80:11115"))
|
||||
peeradd:value("tcp://hw.gz.9z1.me:58443", translate("广州V4-tcp://hw.gz.9z1.me:58443"))
|
||||
peeradd:value("tcp://c.oee.icu:60006", translate("香港V4/V6-tcp://c.oee.icu:60006"))
|
||||
peeradd:value("udp://c.oee.icu:60006", translate("香港V4/V6-udp://c.oee.icu:60006"))
|
||||
peeradd:value("wss://c.oee.icu:60007", translate("香港V4/V6-wss://c.oee.icu:60007"))
|
||||
peeradd:value("tcp://etvm.oee.icu:31572", translate("日本V4-tcp://etvm.oee.icu:31572"))
|
||||
peeradd:value("wss://etvm.oee.icu:30845", translate("日本V4-wss://etvm.oee.icu:30845"))
|
||||
peeradd:value("tcp://et.pub.moe.gift:11010", translate("美国科罗拉多V4-tcp://et.pub.moe.gift:11010"))
|
||||
peeradd:value("wss://et.pub.moe.gift:11012", translate("美国科罗拉多V4-tcp://et.pub.moe.gift:11012"))
|
||||
peeradd:value("tcp://et.323888.xyz:11010", translate("湖北十堰V4-tcp://et.323888.xyz:11010"))
|
||||
peeradd:value("udp://et.323888.xyz:11010", translate("湖北十堰V4-udp://et.323888.xyz:11010"))
|
||||
peeradd:value("wss://et.323888.xyz:11012", translate("湖北十堰V4-wss://et.323888.xyz:11012"))
|
||||
peeradd:value("tcp://s1.ct8.pl:1101", translate("德国萨克森V4-tcp://s1.ct8.pl:1101"))
|
||||
peeradd:value("ws://s1.ct8.pl:11012", translate("德国萨克森V4-ws://s1.ct8.pl:11012"))
|
||||
|
||||
external_node = s:taboption("general", Value, "external_node", translate("共享节点地址"),
|
||||
translate("使用公共共享节点来发现对等节点,和上方参数作用一样 (-e 参数)"))
|
||||
external_node.default = ""
|
||||
external_node.placeholder = "tcp://public.easytier.top:11010"
|
||||
external_node:value("tcp://public.easytier.top:11010", translate("官方公共服务器-广东河源-tcp://public.easytier.top:11010"))
|
||||
|
||||
proxy_network = s:taboption("general",DynamicList, "proxy_network", translate("子网代理"),
|
||||
translate("将本地网络导出到 VPN 中的其他对等点,可访问当前局域网内其他设备 (-n 参数)"))
|
||||
|
||||
rpc_portal = s:taboption("privacy", Value, "rpc_portal", translate("门户地址端口"),
|
||||
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("监听端口"),
|
||||
translate("OFF:不监听任何端口,只连接到对等节点 (--no-listener 参数)<br>单纯作为客户端使用(不作为服务器)可以不监听端口"))
|
||||
listenermode:value("ON",translate("监听"))
|
||||
listenermode:value("OFF",translate("不监听"))
|
||||
listenermode.default = "OFF"
|
||||
|
||||
listener6 = s:taboption("general",Flag, "listener6", translate("同时监听IPV6"),
|
||||
translate("默认只监听IPV4,对等节点只能使用IPV4连接,启用后将同时监听IPV6,例如 -l tcp://[::]:11010"))
|
||||
listener6: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.default = "11010"
|
||||
tcp_port:depends("listenermode", "ON")
|
||||
|
||||
ws_port = s:taboption("general",Value, "ws_port", translate("ws端口"),
|
||||
translate("ws协议,端口号:11011,表示 ws 将在 11011 上监听"))
|
||||
ws_port.datatype = "range(1,65535)"
|
||||
ws_port.default = "11011"
|
||||
ws_port:depends("listenermode", "ON")
|
||||
|
||||
wss_port = s:taboption("general",Value, "wss_port", translate("wss端口"),
|
||||
translate("wss协议,端口号:11012,表示 wss 将在 11012 上监听"))
|
||||
wss_port.datatype = "range(1,65535)"
|
||||
wss_port.default = "11012"
|
||||
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 = nixio.fs.readfile("/proc/device-tree/model") or ""
|
||||
local hostname = nixio.fs.readfile("/proc/sys/kernel/hostname") or ""
|
||||
model = model:gsub("\n", "")
|
||||
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 参数)"))
|
||||
desvice_name.placeholder = device_name
|
||||
desvice_name.default = device_name
|
||||
|
||||
instance_name = s:taboption("privacy",Value, "instance_name", translate("实例名称"),
|
||||
translate("用于在同一台机器中标识此 VPN 节点的实例名称 (--instance-name 参数)"))
|
||||
instance_name.placeholder = "default"
|
||||
|
||||
vpn_portal = s:taboption("privacy",Value, "vpn_portal", translate("VPN门户URL"),
|
||||
translate("定义 VPN 门户的 URL,允许其他 VPN 客户端连接。<br> 示例:wg://0.0.0.0:11011/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:11011/10.14.14.0/24"
|
||||
|
||||
mtu = s:taboption("privacy",Value, "mtu", translate("MTU"),
|
||||
translate("TUN 设备的 MTU,默认值为非加密时的 1380,加密时为 1360"))
|
||||
mtu.datatype = "range(1,1500)"
|
||||
mtu.placeholder = "1300"
|
||||
|
||||
default_protocol = s:taboption("privacy",ListValue, "default_protocol", translate("默认协议"),
|
||||
translate("连接对等节点时使用的默认协议(--default-protocol 参数)"))
|
||||
default_protocol:value("-",translate("默认"))
|
||||
default_protocol:value("tcp")
|
||||
default_protocol:value("udp")
|
||||
default_protocol:value("ws")
|
||||
default_protocol:value("wss")
|
||||
|
||||
tunname = s:taboption("privacy",Value, "tunname", translate("虚拟网卡名称"),
|
||||
translate("自定义虚拟网卡TUN接口的名称(--dev-name 参数)"))
|
||||
tunname.placeholder = "easytier"
|
||||
|
||||
disable_encryption = s:taboption("general",Flag, "disable_encryption", translate("禁用加密"),
|
||||
translate("禁用对等节点通信的加密,若关闭加密则其他节点也必须关闭加密 (-u 参数)"))
|
||||
|
||||
multi_thread = s:taboption("general",Flag, "multi_thread", translate("启用多线程"),
|
||||
translate("使用多线程运行时,默认为单线程 (--multi-thread 参数)"))
|
||||
|
||||
disable_ipv6 = s:taboption("privacy",Flag, "disable_ipv6", translate("禁用ipv6"),
|
||||
translate("不使用ipv6 (--disable-ipv6 参数)"))
|
||||
|
||||
latency_first = s:taboption("general",Flag, "latency_first", translate("启用延迟优先"),
|
||||
translate("延迟优先模式,将尝试使用最低延迟路径转发流量,默认使用最短路径 (--latency-first 参数)"))
|
||||
|
||||
exit_node = s:taboption("privacy",Flag, "exit_node", translate("启用出口节点"),
|
||||
translate("允许此节点成为出口节点 (--enable-exit-node 参数)"))
|
||||
|
||||
exit_nodes = s:taboption("privacy",DynamicList, "exit_nodes", translate("出口节点地址"),
|
||||
translate("转发所有流量的出口节点,虚拟 IPv4 地址,优先级由列表顺序确定(--exit-nodes 参数)"))
|
||||
|
||||
smoltcp = s:taboption("privacy",Flag, "smoltcp", translate("启用smoltcp堆栈"),
|
||||
translate("为子网代理启用smoltcp堆栈(--use-smoltcp 参数)"))
|
||||
smoltcp.rmempty = false
|
||||
|
||||
no_tun = s:taboption("privacy",Flag, "no_tun", translate("无tun模式"),
|
||||
translate("不创建TUN设备,可以使用子网代理访问节点( --no-tun 参数)"))
|
||||
no_tun.rmempty = false
|
||||
|
||||
manual_routes = s:taboption("privacy",DynamicList, "manual_routes", translate("路由CIDR"),
|
||||
translate("手动分配路由CIDR,将禁用子网代理和从对等节点传播的wireguard路由。(--manual-routes 参数)"))
|
||||
manual_routes.placeholder = "192.168.0.0/16"
|
||||
|
||||
relay_network = s:taboption("privacy",Flag, "relay_network", translate("转发白名单网络的流量"),
|
||||
translate("仅转发白名单网络的流量,默认允许所有网络"))
|
||||
relay_network.rmempty = false
|
||||
|
||||
whitelist = s:taboption("privacy",DynamicList, "whitelist", translate("白名单网络"),
|
||||
translate("仅转发白名单网络的流量,输入是通配符字符串,例如:'*'(所有网络),'def*'(以def为前缀的网络)<br>可以指定多个网络。如果参数为空,则禁用转发。(--relay-network-whitelist 参数)"))
|
||||
whitelist:depends("relay_network", "1")
|
||||
|
||||
socks_port = s:taboption("privacy",Value, "socks_port", translate("socks5端口"),
|
||||
translate("启用 socks5 服务器,允许 socks5 客户端访问虚拟网络,留空则不开启(--socks5 参数)"))
|
||||
socks_port.datatype = "range(1,65535)"
|
||||
socks_port.placeholder = "1080"
|
||||
|
||||
disable_p2p = s:taboption("privacy",Flag, "disable_p2p", translate("禁用P2P"),
|
||||
translate("禁用P2P通信,只通过-p指定的节点转发数据包 ( --disable-p2p 参数)"))
|
||||
disable_p2p.rmempty = false
|
||||
|
||||
disable_udp = s:taboption("privacy",Flag, "disable_udp", translate("禁用UDP"),
|
||||
translate("禁用UDP打洞功能( --disable-udp-hole-punching 参数)"))
|
||||
disable_udp.rmempty = false
|
||||
|
||||
relay_all = s:taboption("privacy",Flag, "relay_all", translate("允许转发"),
|
||||
translate("转发所有对等节点的RPC数据包,即使对等节点不在转发网络白名单中。<br>这可以帮助白名单外网络中的对等节点建立P2P连接。"))
|
||||
relay_all.rmempty = false
|
||||
|
||||
log = s:taboption("general",ListValue, "log", translate("程序日志"),
|
||||
translate("运行日志在/tmp/easytier.log,可在上方日志查看<br>若启动失败,请前往 状态- 系统日志 查看具体启动失败日志<br>详细程度:警告<信息<调试<跟踪"))
|
||||
log.default = "info"
|
||||
log:value("off",translate("关闭"))
|
||||
log:value("warn",translate("警告"))
|
||||
log:value("info",translate("信息"))
|
||||
log:value("debug",translate("调试"))
|
||||
log:value("trace",translate("跟踪"))
|
||||
|
||||
check = s:taboption("privacy",Flag, "check", translate("通断检测"),
|
||||
translate("开启通断检测后,可以指定对端的设备IP,当所有指定的IP都ping不通时将会重启easytier程序"))
|
||||
|
||||
checkip=s:taboption("privacy",DynamicList,"checkip",translate("检测IP"),
|
||||
translate("确保这里的对端设备IP地址填写正确且可访问,若填写错误将会导致无法ping通,程序反复重启"))
|
||||
checkip.rmempty = true
|
||||
checkip.datatype = "ip4addr"
|
||||
checkip:depends("check", "1")
|
||||
|
||||
checktime = s:taboption("privacy",ListValue, "checktime", translate("间隔时间 (分钟)"),
|
||||
translate("检测间隔的时间,每隔多久检测指定的IP通断一次"))
|
||||
for s=1,60 do
|
||||
checktime:value(s)
|
||||
end
|
||||
checktime:depends("check", "1")
|
||||
|
||||
local process_status = luci.sys.exec("ps | grep easytier-core| grep -v grep")
|
||||
|
||||
btn0 = s:taboption("infos", Button, "btn0")
|
||||
btn0.inputtitle = translate("node信息")
|
||||
btn0.description = translate("点击按钮刷新,查看本机信息")
|
||||
btn0.inputstyle = "apply"
|
||||
btn0.write = function()
|
||||
if process_status ~= "" then
|
||||
luci.sys.call("$(dirname $(uci -q get easytier.@easytier[0].easytierbin))/easytier-cli node >/tmp/easytier-cli_node")
|
||||
else
|
||||
luci.sys.call("echo '错误:程序未运行!请启动程序后重新点击刷新' >/tmp/easytier-cli_node")
|
||||
end
|
||||
end
|
||||
|
||||
btn0info = s:taboption("infos", DummyValue, "btn0info")
|
||||
btn0info.rawhtml = true
|
||||
btn0info.cfgvalue = function(self, section)
|
||||
local content = nixio.fs.readfile("/tmp/easytier-cli_node") or ""
|
||||
return string.format("<pre>%s</pre>", luci.util.pcdata(content))
|
||||
end
|
||||
|
||||
btn1 = s:taboption("infos", Button, "btn1")
|
||||
btn1.inputtitle = translate("peer信息")
|
||||
btn1.description = translate("点击按钮刷新,查看对端信息")
|
||||
btn1.inputstyle = "apply"
|
||||
btn1.write = function()
|
||||
if process_status ~= "" then
|
||||
luci.sys.call("$(dirname $(uci -q get easytier.@easytier[0].easytierbin))/easytier-cli peer >/tmp/easytier-cli_peer")
|
||||
else
|
||||
luci.sys.call("echo '错误:程序未运行!请启动程序后重新点击刷新' >/tmp/easytier-cli_peer")
|
||||
end
|
||||
end
|
||||
|
||||
btn1info = s:taboption("infos", DummyValue, "btn1info")
|
||||
btn1info.rawhtml = true
|
||||
btn1info.cfgvalue = function(self, section)
|
||||
local content = nixio.fs.readfile("/tmp/easytier-cli_peer") or ""
|
||||
return string.format("<pre>%s</pre>", luci.util.pcdata(content))
|
||||
end
|
||||
|
||||
btn2 = s:taboption("infos", Button, "btn2")
|
||||
btn2.inputtitle = translate("connector信息")
|
||||
btn2.description = translate("点击按钮刷新,查看connector信息")
|
||||
btn2.inputstyle = "apply"
|
||||
btn2.write = function()
|
||||
if process_status ~= "" then
|
||||
luci.sys.call("$(dirname $(uci -q get easytier.@easytier[0].easytierbin))/easytier-cli connector >/tmp/easytier-cli_connector")
|
||||
else
|
||||
luci.sys.call("echo '错误:程序未运行!请启动程序后重新点击刷新' >/tmp/easytier-cli_connector")
|
||||
end
|
||||
end
|
||||
|
||||
btn2info = s:taboption("infos", DummyValue, "btn2info")
|
||||
btn2info.rawhtml = true
|
||||
btn2info.cfgvalue = function(self, section)
|
||||
local content = nixio.fs.readfile("/tmp/easytier-cli_connector") or ""
|
||||
return string.format("<pre>%s</pre>", luci.util.pcdata(content))
|
||||
end
|
||||
|
||||
btn3 = s:taboption("infos", Button, "btn3")
|
||||
btn3.inputtitle = translate("stun信息")
|
||||
btn3.description = translate("点击按钮刷新,查看stun信息")
|
||||
btn3.inputstyle = "apply"
|
||||
btn3.write = function()
|
||||
if process_status ~= "" then
|
||||
luci.sys.call("$(dirname $(uci -q get easytier.@easytier[0].easytierbin))/easytier-cli stun >/tmp/easytier-cli_stun")
|
||||
else
|
||||
luci.sys.call("echo '错误:程序未运行!请启动程序后重新点击刷新' >/tmp/easytier-cli_stun")
|
||||
end
|
||||
end
|
||||
|
||||
btn3info = s:taboption("infos", DummyValue, "btn3info")
|
||||
btn3info.rawhtml = true
|
||||
btn3info.cfgvalue = function(self, section)
|
||||
local content = nixio.fs.readfile("/tmp/easytier-cli_stun") or ""
|
||||
return string.format("<pre>%s</pre>", luci.util.pcdata(content))
|
||||
end
|
||||
|
||||
|
||||
btn4 = s:taboption("infos", Button, "btn4")
|
||||
btn4.inputtitle = translate("route信息")
|
||||
btn4.description = translate("点击按钮刷新,查看route信息")
|
||||
btn4.inputstyle = "apply"
|
||||
btn4.write = function()
|
||||
if process_status ~= "" then
|
||||
luci.sys.call("$(dirname $(uci -q get easytier.@easytier[0].easytierbin))/easytier-cli route >/tmp/easytier-cli_route")
|
||||
else
|
||||
luci.sys.call("echo '错误:程序未运行!请启动程序后重新点击刷新' >/tmp/easytier-cli_route")
|
||||
end
|
||||
end
|
||||
|
||||
btn4info = s:taboption("infos", DummyValue, "btn4info")
|
||||
btn4info.rawhtml = true
|
||||
btn4info.cfgvalue = function(self, section)
|
||||
local content = nixio.fs.readfile("/tmp/easytier-cli_route") or ""
|
||||
return string.format("<pre>%s</pre>", luci.util.pcdata(content))
|
||||
end
|
||||
|
||||
btn6 = s:taboption("infos", Button, "btn6")
|
||||
btn6.inputtitle = translate("peer-center信息")
|
||||
btn6.description = translate("点击按钮刷新,查看peer-center信息")
|
||||
btn6.inputstyle = "apply"
|
||||
btn6.write = function()
|
||||
if process_status ~= "" then
|
||||
luci.sys.call("$(dirname $(uci -q get easytier.@easytier[0].easytierbin))/easytier-cli peer-center >/tmp/easytier-cli_peer-center")
|
||||
else
|
||||
luci.sys.call("echo '错误:程序未运行!请启动程序后重新点击刷新' >/tmp/easytier-cli_peer-center")
|
||||
end
|
||||
end
|
||||
|
||||
btn6info = s:taboption("infos", DummyValue, "btn6info")
|
||||
btn6info.rawhtml = true
|
||||
btn6info.cfgvalue = function(self, section)
|
||||
local content = nixio.fs.readfile("/tmp/easytier-cli_peer-center") or ""
|
||||
return string.format("<pre>%s</pre>", luci.util.pcdata(content))
|
||||
end
|
||||
|
||||
btn7 = s:taboption("infos", Button, "btn7")
|
||||
btn7.inputtitle = translate("vpn-portal信息")
|
||||
btn7.description = translate("点击按钮刷新,查看vpn-portal信息")
|
||||
btn7.inputstyle = "apply"
|
||||
btn7.write = function()
|
||||
if process_status ~= "" then
|
||||
luci.sys.call("$(dirname $(uci -q get easytier.@easytier[0].easytierbin))/easytier-cli vpn-portal >/tmp/easytier-cli_vpn-portal")
|
||||
else
|
||||
luci.sys.call("echo '错误:程序未运行!请启动程序后重新点击刷新' >/tmp/easytier-cli_vpn-portal")
|
||||
end
|
||||
end
|
||||
|
||||
btn7info = s:taboption("infos", DummyValue, "btn7info")
|
||||
btn7info.rawhtml = true
|
||||
btn7info.cfgvalue = function(self, section)
|
||||
local content = nixio.fs.readfile("/tmp/easytier-cli_vpn-portal") or ""
|
||||
return string.format("<pre>%s</pre>", luci.util.pcdata(content))
|
||||
end
|
||||
|
||||
btn5 = s:taboption("infos", Button, "btn5")
|
||||
btn5.inputtitle = translate("本机启动参数")
|
||||
btn5.description = translate("点击按钮刷新,查看本机完整启动参数")
|
||||
btn5.inputstyle = "apply"
|
||||
btn5.write = function()
|
||||
if process_status ~= "" then
|
||||
luci.sys.call("echo $(cat /proc/$(pidof easytier-core)/cmdline | awk '{print $1}') >/tmp/easytier_cmd")
|
||||
else
|
||||
luci.sys.call("echo '错误:程序未运行!请启动程序后重新点击刷新' >/tmp/easytier_cmd")
|
||||
end
|
||||
end
|
||||
|
||||
btn5cmd = s:taboption("infos", DummyValue, "btn5cmd")
|
||||
btn5cmd.rawhtml = true
|
||||
btn5cmd.cfgvalue = function(self, section)
|
||||
local content = nixio.fs.readfile("/tmp/easytier_cmd") or ""
|
||||
return string.format("<pre>%s</pre>", luci.util.pcdata(content))
|
||||
end
|
||||
|
||||
btnrm = s:taboption("infos", Button, "btnrm")
|
||||
btnrm.inputtitle = translate("检测更新")
|
||||
btnrm.description = translate("点击按钮开始检测更新,上方状态栏显示")
|
||||
btnrm.inputstyle = "apply"
|
||||
btnrm.write = function()
|
||||
os.execute("rm -rf /tmp/easytier*.tag /tmp/easytier*.newtag /tmp/easytier-core_*")
|
||||
end
|
||||
|
||||
|
||||
easytierbin = s:taboption("upload", Value, "easytierbin", translate("easytier-core程序路径"),
|
||||
translate("自定义easytier-core的存放路径,确保填写完整的路径及名称,若指定的路径可用空间不足将会自动移至/tmp/easytier-core"))
|
||||
easytierbin.placeholder = "/tmp/vnt-cli"
|
||||
|
||||
local upload = s:taboption("upload", FileUpload, "upload_file")
|
||||
upload.optional = true
|
||||
upload.default = ""
|
||||
upload.template = "easytier/other_upload"
|
||||
upload.description = translate("可直接上传二进制程序easytier-core和easytier-cli或者以.zip结尾的压缩包,上传新版本会自动覆盖旧版本,下载地址:<a href='https://github.com/EasyTier/EasyTier/releases' target='_blank'>github.com/EasyTier/EasyTier</a><br>上传的文件将会保存在/tmp文件夹里,如果自定义了程序路径那么启动程序时将会自动移至自定义的路径<br>")
|
||||
local um = s:taboption("upload",DummyValue, "", nil)
|
||||
um.template = "easytier/other_dvalue"
|
||||
|
||||
local dir, fd, chunk
|
||||
dir = "/tmp/"
|
||||
nixio.fs.mkdir(dir)
|
||||
http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not fd then
|
||||
if not meta then return end
|
||||
|
||||
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
|
||||
|
||||
if not fd then
|
||||
um.value = translate("错误:上传失败!")
|
||||
return
|
||||
end
|
||||
end
|
||||
if chunk and fd then
|
||||
fd:write(chunk)
|
||||
end
|
||||
if eof and fd then
|
||||
fd:close()
|
||||
fd = nil
|
||||
um.value = translate("文件已上传至") .. ' "/tmp/' .. meta.file .. '"'
|
||||
|
||||
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
|
||||
if nixio.fs.access("/tmp/easytier-core") then
|
||||
um.value = um.value .. "\n" .. translate("-程序/tmp/easytier-core上传成功,重启一次插件才生效")
|
||||
end
|
||||
end
|
||||
if string.sub(meta.file, -7) == ".tar.gz" then
|
||||
local file_path = dir .. meta.file
|
||||
os.execute("tar -xzf " .. file_path .. " -C " .. 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
|
||||
if nixio.fs.access("/tmp/easytier-core") then
|
||||
um.value = um.value .. "\n" .. translate("-程序/tmp/easytier-core上传成功,重启一次插件才生效")
|
||||
end
|
||||
end
|
||||
os.execute("chmod +x /tmp/easytier-core")
|
||||
os.execute("chmod +x /tmp/easytier-cli")
|
||||
end
|
||||
end
|
||||
)
|
||||
if luci.http.formvalue("upload") then
|
||||
local f = luci.http.formvalue("ulfile")
|
||||
end
|
||||
|
||||
return m
|
5
luci-app-easytier/luasrc/model/cbi/easytier_log.lua
Normal file
5
luci-app-easytier/luasrc/model/cbi/easytier_log.lua
Normal file
@ -0,0 +1,5 @@
|
||||
f = SimpleForm("easytier")
|
||||
f.reset = false
|
||||
f.submit = false
|
||||
f:append(Template("easytier/easytier_log"))
|
||||
return f
|
33
luci-app-easytier/luasrc/view/easytier/easytier_log.htm
Normal file
33
luci-app-easytier/luasrc/view/easytier/easytier_log.htm
Normal file
@ -0,0 +1,33 @@
|
||||
<%
|
||||
local dsp = require "luci.dispatcher"
|
||||
-%>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function clearlog(btn) {
|
||||
XHR.get('<%=dsp.build_url("admin/vpn/easytier/clear_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = "";
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
XHR.poll(2, '<%=dsp.build_url("admin/vpn/easytier/get_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200 && document.getElementById("checkbox1").checked == true) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = x.responseText;
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<fieldset class="cbi-section" id="_log_fieldset">
|
||||
<input type="checkbox" id="checkbox1" style="vertical-align:middle;height: auto;"checked><%:自动刷新%></input>
|
||||
<input class="cbi-button cbi-input-remove" type="button" onclick="clearlog()" value="<%:清除日志%>" />
|
||||
<textarea id="log_textarea" class="cbi-input-textarea" style="width: 100%;margin-top: 10px;" data-update="change" rows="30" wrap="off" readonly="readonly"></textarea>
|
||||
</fieldset>
|
23
luci-app-easytier/luasrc/view/easytier/easytier_status.htm
Normal file
23
luci-app-easytier/luasrc/view/easytier/easytier_status.htm
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[vpn]], [[easytier]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var st = document.getElementById('easytier_status');
|
||||
if (data && st) {
|
||||
var clientStatus = data.crunning ? "<span style='color:green;'> 运行中</span><img src='https://www.right.com.cn/forum/data/attachment/album/202401/30/081238k459q2d5klacs8rk.gif' width='30px' alt=''>" : "<span style='color:red;'> 未运行</span>";
|
||||
var etstaContent = data.crunning ? "已运行:" + "<span style='color:#DA70D6;'>" + data.etsta + "</span>" : "";
|
||||
var etcpuContent = data.crunning ? "<br>" + "CPU占用:" + "<span style='color:#6A5ACD;'>" + data.etcpu + "</span>" : "";
|
||||
var etramContent = data.crunning ? " " + " 内存占用:" + "<span style='color:#0000CD;'>" + data.etram + "</span>" : "";
|
||||
var ettagContent = data.crunning ? "<br>" + "当前版本:" + "<span style='color:#CD853F;'>" + data.ettag + "</span>" : "";
|
||||
var etnewtagContent = data.crunning ? " " + " 最新版本:" + "<span style='color:#FFA500;'>" + data.etnewtag + "</span>" : "";
|
||||
st.innerHTML = "<em><b>easytier-core " + clientStatus + etstaContent + etcpuContent + etramContent + ettagContent + etnewtagContent + "</b></em>";
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="easytier_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
8
luci-app-easytier/luasrc/view/easytier/other_dvalue.htm
Normal file
8
luci-app-easytier/luasrc/view/easytier/other_dvalue.htm
Normal file
@ -0,0 +1,8 @@
|
||||
<%+cbi/valueheader%>
|
||||
<span style="color: red">
|
||||
<%
|
||||
local val = self:cfgvalue(section) or self.default or ""
|
||||
write(pcdata(val))
|
||||
%>
|
||||
</span>
|
||||
<%+cbi/valuefooter%>
|
5
luci-app-easytier/luasrc/view/easytier/other_upload.htm
Normal file
5
luci-app-easytier/luasrc/view/easytier/other_upload.htm
Normal file
@ -0,0 +1,5 @@
|
||||
<%+cbi/valueheader%>
|
||||
<label class="cbi-value" style="display:inline-block; width: 130px" for="ulfile"><%:上传程序:%></label>
|
||||
<input class="cbi-input-file" style="width: 400px" type="file" id="ulfile" name="ulfile" />
|
||||
<input type="submit" class="cbi-button cbi-input-apply" name="upload" value="<%:Upload%>" />
|
||||
<%+cbi/valuefooter%>
|
4
luci-app-easytier/root/etc/config/easytier
Normal file
4
luci-app-easytier/root/etc/config/easytier
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
config easytier
|
||||
option enabled '0'
|
||||
option easytierbin '/usr/bin/easytier-core'
|
18
luci-app-easytier/root/etc/easytier/config.toml
Normal file
18
luci-app-easytier/root/etc/easytier/config.toml
Normal file
@ -0,0 +1,18 @@
|
||||
instance_name = "default"
|
||||
instance_id = "f9f05421-7c6b-47d6-a67d-4d58d49f51d8"
|
||||
dhcp = true
|
||||
listeners = []
|
||||
exit_nodes = []
|
||||
rpc_portal = "0.0.0.0:15888"
|
||||
|
||||
[network_identity]
|
||||
network_name = "mynetwork"
|
||||
network_secret = "mysecret"
|
||||
|
||||
[[peer]]
|
||||
uri = "tcp://public.easytier.top:11010"
|
||||
|
||||
[file_logger]
|
||||
level = "info"
|
||||
file = "easytier-default"
|
||||
dir = "/tmp"
|
522
luci-app-easytier/root/etc/init.d/easytier
Normal file
522
luci-app-easytier/root/etc/init.d/easytier
Normal file
@ -0,0 +1,522 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2008-2020 OpenWrt.org
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
size="$(df -k | awk '/\/overlay$/ {sub(/K$/, "", $4); print $4}')"
|
||||
[ -z "$size" ] && size="$(df -k /usr/bin | awk 'NR==2 {print $(NF-2) }')"
|
||||
|
||||
check () {
|
||||
if [ ! -z "$checkip" ] ; then
|
||||
echo ' ' >/tmp/easytier_check
|
||||
cat > /tmp/easytier_check<<'EOF'
|
||||
#!/bin/sh
|
||||
time="$(($(uci -q get easytier.@easytier[0].checktime) * 60))"
|
||||
if [ -z "$time" ] ;then
|
||||
time=120
|
||||
uci -q set easytier.@easytier[0].checktime=2
|
||||
uci commit easytier
|
||||
fi
|
||||
while true; do
|
||||
if [ "$(uci -q get easytier.@easytier[0].enabled)" = "1" ] ; then
|
||||
ping -c 3 223.5.5.5 -w 5 >/dev/null 2>&1
|
||||
if [ "$?" == "0" ]; then
|
||||
if [ ! -z "$(uci -q get easytier.@easytier[0].checkip)" ] ; then
|
||||
online=""
|
||||
for ip in $(uci -q get easytier.@easytier[0].checkip); do
|
||||
ms=`echo $(ping -4 $ip -c 2 -w 4 -q) | awk -F '/' '{print $4}'`
|
||||
[ ! -z "$ms" ] && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 通断检测:${ip} 延迟:${ms}ms " >>/tmp/easytier.log && online=1
|
||||
[ -z "$ms" ] && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 通断检测:${ip} 网络中断 " >>/tmp/easytier.log
|
||||
done
|
||||
[ "$online" != "1" ] && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 通断检测:$(uci -q get easytier.@easytier[0].checkip) 所有指定IP皆无法ping通,重新启动程序! " >>/tmp/easytier.log && /etc/init.d/easytier restart
|
||||
fi
|
||||
else
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 通断检测:检测到互联网未能成功访问,跳过检测 " >>/tmp/easytier.log
|
||||
fi
|
||||
else
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 通断检测:程序已关闭,退出检测 " >>/tmp/easytier.log
|
||||
/etc/init.d/easytier restart
|
||||
break
|
||||
fi
|
||||
sleep $((time))
|
||||
[ "$(du -k /log/easytier.log | cut -f1)" = "1000" ] && echo " " >/tmp/easytier.log
|
||||
done
|
||||
EOF
|
||||
chmod +x /tmp/easytier_check
|
||||
/tmp/easytier_check &
|
||||
fi
|
||||
}
|
||||
|
||||
start_et() {
|
||||
local cfg="$1"
|
||||
local enabled easytierbin etcmd
|
||||
config_get_bool enabled "$cfg" 'enabled' '0'
|
||||
[ "$enabled" = "1" ] || return 1
|
||||
config_get easytierbin "$cfg" 'easytierbin' '/tmp/easytier-core'
|
||||
config_get etcmd "$cfg" 'etcmd' 'etcmd'
|
||||
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
|
||||
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
|
||||
chmod +x /tmp/easytier-cli 2>/dev/null
|
||||
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)
|
||||
[ -z "$size"] && echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 获取可用空间失败,请使用ssh手动上传至 ${easytierbin} ${path}/easytier-cli" >>/tmp/easytier.log
|
||||
if [ $(($(/tmp/easytier-core -h | wc -l))) -gt 3 ] && [ "$result" -gt 1000 ] ; then
|
||||
mv -f /tmp/easytier-core "$easytierbin" 2>/dev/null
|
||||
mv -f /tmp/easytier-cli "${path}/easytier-cli" 2>/dev/null
|
||||
else
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 无法替换,上传的程序不完整或自定义路径的可用空间不足,当前空间剩余${size}kb" >>/tmp/easytier.log
|
||||
fi
|
||||
fi
|
||||
if [ ! -f "$easytierbin" ] && [ "$size" -lt 5000 ] ; then
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 自定义程序路径的可用空间不足,当前可用空间剩余${size}kb,自动切换为内存/tmp/easytier-core" >>/tmp/easytier.log
|
||||
sed -i "/easytierbin/c option easytierbin '/tmp/easytier-core' " /etc/config/easytier
|
||||
easytierbin=/tmp/easytier-core
|
||||
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="$( 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=v2.0.3
|
||||
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 "https://ghp.ci/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://ghproxy.net/https://github.com/EasyTier/EasyTier/releases/download/${newtag}/easytier-linux-${cpucore}-${newtag}.zip" || wget --no-check-certificate --quiet --timeout=10 --tries=3 -O /tmp/easytier.zip "https://gh-proxy.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 : 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 ${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
|
||||
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
|
||||
if [ "$etcmd" = "config" ] ; then
|
||||
config_file="/etc/easytier/config.toml"
|
||||
instance_name=$(cat $config_file | grep "instance_name =" | awk '{print $3}'| tr -d '" ')
|
||||
socks_port=$(cat $config_file | grep "socks5_proxy" | awk -F ":" '{print $3}'| tr -d '" ')
|
||||
[ -z "$(grep -F 'listeners = []' $config_file)" ] && listenermode="ON"
|
||||
tcp_port=$(cat $config_file | grep "tcp://0.0.0.0" | awk -F ":" '{print $3}'| tr -d '", ')
|
||||
udp_port=$(cat $config_file | grep "udp://0.0.0.0" | awk -F ":" '{print $3}'| tr -d '", ')
|
||||
ws_port=$(cat $config_file | grep "ws://0.0.0.0" | awk -F ":" '{print $3}'| tr -d '"/, ')
|
||||
wss_port=$(cat $config_file | grep "wss://0.0.0.0" | awk -F ":" '{print $3}'| tr -d '"/, ')
|
||||
wg_port=$(cat $config_file | grep "wg://0.0.0.0" | awk -F ":" '{print $3}'| tr -d '", ')
|
||||
tunname=$(cat $config_file | grep "dev_name =" | awk '{print $3}'| tr -d '", ')
|
||||
proxy_network=$(grep -F '[[proxy_network]]' $config_file)
|
||||
wireguard_port=$(cat $config_file | grep "wireguard_listen = " | awk -F ":" '{print $2}'| tr -d '/", ')
|
||||
v6ws_port=$(cat $config_file | grep 'ws://\[::\]:' | sed -n 's/.*:\([0-9]*\)\/.*/\1/p')
|
||||
v6wss_port=$(cat $config_file | grep 'wss://\[::\]:' | sed -n 's/.*:\([0-9]*\)\/.*/\1/p')
|
||||
v6tcp_port=$(cat $config_file |grep 'tcp://\[::\]:' | sed -n 's/.*:\([0-9]*\).*/\1/p')
|
||||
v6udp_port=$(cat $config_file |grep 'udp://\[::\]:' | sed -n 's/.*:\([0-9]*\).*/\1/p')
|
||||
v6wg_port=$(cat $config_file |grep 'wg://\[::\]:' | sed -n 's/.*:\([0-9]*\).*/\1/p')
|
||||
|
||||
procd_open_instance "easytier"
|
||||
procd_set_param command "$easytierbin"
|
||||
procd_append_param command -c "$config_file"
|
||||
|
||||
if [ ! -z "$udp_port" ] ; then
|
||||
uci -q delete firewall.easytier_udp
|
||||
uci set firewall.easytier_udp=rule
|
||||
uci set firewall.easytier_udp.name="easytier_udp"
|
||||
uci set firewall.easytier_udp.target="ACCEPT"
|
||||
uci set firewall.easytier_udp.src="wan"
|
||||
uci set firewall.easytier_udp.proto="all"
|
||||
uci set firewall.easytier_udp.dest_port="$udp_port"
|
||||
uci set firewall.easytier_udp.enabled="1"
|
||||
fi
|
||||
if [ ! -z "$wireguard_port" ] ; then
|
||||
uci -q delete firewall.easytier_wireguard
|
||||
uci set firewall.easytier_wireguard=rule
|
||||
uci set firewall.easytier_wireguard.name="easytier_wireguard"
|
||||
uci set firewall.easytier_wireguard.target="ACCEPT"
|
||||
uci set firewall.easytier_wireguard.src="wan"
|
||||
uci set firewall.easytier_wireguard.proto="udp"
|
||||
uci set firewall.easytier_wireguard.dest_port="$wireguard_port"
|
||||
uci set firewall.easytier_wireguard.enabled="1"
|
||||
fi
|
||||
if [ ! -z "$v6tcp_port" ] ; then
|
||||
uci -q delete firewall.easytier_v6tcp
|
||||
uci set firewall.easytier_v6tcp=rule
|
||||
uci set firewall.easytier_v6tcp.name="easytier_v6tcp"
|
||||
uci set firewall.easytier_v6tcp.target="ACCEPT"
|
||||
uci set firewall.easytier_v6tcp.src="wan"
|
||||
uci set firewall.easytier_v6tcp.proto="tcp"
|
||||
uci set firewall.easytier_v6tcp.dest_port="$v6tcp_port"
|
||||
uci set firewall.easytier_v6tcp.enabled="1"
|
||||
fi
|
||||
if [ ! -z "$v6udp_port" ] ; then
|
||||
uci -q delete firewall.easytier_v6udp
|
||||
uci set firewall.easytier_v6udp=rule
|
||||
uci set firewall.easytier_v6udp.name="easytier_v6udp"
|
||||
uci set firewall.easytier_v6udp.target="ACCEPT"
|
||||
uci set firewall.easytier_v6udp.src="wan"
|
||||
uci set firewall.easytier_v6udp.proto="udp"
|
||||
uci set firewall.easytier_v6udp.dest_port="$v6udp_port"
|
||||
uci set firewall.easytier_v6udp.enabled="1"
|
||||
fi
|
||||
if [ ! -z "$v6ws_port" ] ; then
|
||||
uci -q delete firewall.easytier_v6ws
|
||||
uci set firewall.easytier_v6ws=rule
|
||||
uci set firewall.easytier_v6ws.name="easytier_v6ws"
|
||||
uci set firewall.easytier_v6ws.target="ACCEPT"
|
||||
uci set firewall.easytier_v6ws.src="wan"
|
||||
uci set firewall.easytier_v6ws.proto="tcp"
|
||||
uci set firewall.easytier_v6ws.dest_port="$v6ws_port"
|
||||
uci set firewall.easytier_v6ws.enabled="1"
|
||||
fi
|
||||
if [ ! -z "$v6wss_port" ] ; then
|
||||
uci -q delete firewall.easytier_v6wss
|
||||
uci set firewall.easytier_v6wss=rule
|
||||
uci set firewall.easytier_v6wss.name="easytier_v6wss"
|
||||
uci set firewall.easytier_v6wss.target="ACCEPT"
|
||||
uci set firewall.easytier_v6wss.src="wan"
|
||||
uci set firewall.easytier_v6wss.proto="tcp"
|
||||
uci set firewall.easytier_v6wss.dest_port="$v6wss_port"
|
||||
uci set firewall.easytier_v6wss.enabled="1"
|
||||
fi
|
||||
if [ ! -z "$v6wg_port" ] ; then
|
||||
uci -q delete firewall.easytier_v6wg
|
||||
uci set firewall.easytier_v6wg=rule
|
||||
uci set firewall.easytier_v6wg.name="easytier_v6wg"
|
||||
uci set firewall.easytier_v6wg.target="ACCEPT"
|
||||
uci set firewall.easytier_v6wg.src="wan"
|
||||
uci set firewall.easytier_v6wg.proto="udp"
|
||||
uci set firewall.easytier_v6wg.dest_port="$v6wg_port"
|
||||
uci set firewall.easytier_v6wg.enabled="1"
|
||||
fi
|
||||
else
|
||||
local network_name network_secret ip_dhcp ipaddr peeradd external_node rpc_portal listenermode tunname relay_network disable_p2p disable_udp
|
||||
local tcp_port ws_port wss_port wg_port desvice_name instance_name vpn_portal mtu default_protocol disable_encryption whitelist socks_port
|
||||
local multi_thread disable_ipv6 latency_first exit_node exit_nodes smoltcp no_tun manual_routes log check checkip proxy_network relay_all listener6
|
||||
|
||||
config_get network_name "$cfg" 'network_name'
|
||||
config_get network_secret "$cfg" 'network_secret'
|
||||
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 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_bool listener6 "$cfg" 'listener6' '0'
|
||||
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'
|
||||
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 log "$cfg" 'log' 'off'
|
||||
config_get_bool check "$cfg" 'check' '0'
|
||||
config_get_bool disable_p2p "$cfg" 'disable_p2p' '0'
|
||||
config_get_bool disable_udp "$cfg" 'disable_udp' '0'
|
||||
config_get_bool relay_all "$cfg" 'relay_all' '0'
|
||||
config_get checkip "$cfg" 'checkip'
|
||||
config_get socks_port "$cfg" 'socks_port'
|
||||
|
||||
procd_open_instance "easytier"
|
||||
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"
|
||||
[ -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"
|
||||
else
|
||||
for peeraddr in $(cat /etc/config/easytier | grep 'list peeradd' | awk -F 'list peeradd' '{print $2}' | sed "s/'/\n/g" | tr -d " ' "); do
|
||||
procd_append_param command -p "$peeraddr"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [ ! -z "$proxy_network" ] ; then
|
||||
if [[ "$(grep "list proxy_network" /etc/config/easytier | awk '{print $3}' | wc -l ) " -eq 1 ]]; then
|
||||
procd_append_param command -n "$proxy_network"
|
||||
else
|
||||
for proxy_networks in $(cat /etc/config/easytier | grep 'list proxy_network' | awk -F 'list proxy_network' '{print $2}' | sed "s/'/\n/g" | tr -d " ' "); do
|
||||
procd_append_param command -n "$proxy_networks"
|
||||
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 "$rpc_portal" ] || procd_append_param command -r "$rpc_portal"
|
||||
[ -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"
|
||||
if [ "$listener6" = "1" ] ; then
|
||||
if [ -z "$tcp_port" ] && [ -z "$ws_port" ] && [ -z "$wss_port" ] && [ -z "$wg_port" ] ; then
|
||||
tcp_port="11010"
|
||||
ws_port="11011"
|
||||
wss_port="11012"
|
||||
wg_port="11011"
|
||||
fi
|
||||
[ -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"
|
||||
fi
|
||||
[ -z "$external_node" ] || procd_append_param command -e "$external_node"
|
||||
[ "$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"
|
||||
[ "$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
|
||||
[ "$log" = "off" ] || procd_append_param command --file-log-level "$log"
|
||||
[ "$log" = "off" ] || procd_append_param command --file-log-dir "/tmp"
|
||||
[ "$log" = "off" ] && procd_append_param command --file-log-level "off"
|
||||
[ "$disable_p2p" = "0" ] || procd_append_param command --disable-p2p
|
||||
[ "$disable_udp" = "0" ] || procd_append_param command --disable-udp-hole-punching
|
||||
[ "$relay_all" = "0" ] || procd_append_param command --relay-all-peer-rpc
|
||||
[ -z "$socks_port" ] || procd_append_param command --socks5 "$socks_port"
|
||||
fi
|
||||
[ ! -z "$instance_name" ] && ln -sf /tmp/easytier-${instance_name}.${date_time} /tmp/easytier.log
|
||||
|
||||
procd_set_param limits core="unlimited"
|
||||
procd_set_param limits nofile="1000000 1000000"
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
if [ ! -z "$socks_port" ] ; then
|
||||
uci -q delete firewall.easytier_socks5
|
||||
uci set firewall.easytier_socks5=rule
|
||||
uci set firewall.easytier_socks5.name="easytier_socks5"
|
||||
uci set firewall.easytier_socks5.target="ACCEPT"
|
||||
uci set firewall.easytier_socks5.src="wan"
|
||||
uci set firewall.easytier_socks5.proto="all"
|
||||
uci set firewall.easytier_socks5.dest_port="$socks_port"
|
||||
uci set firewall.easytier_socks5.enabled="1"
|
||||
fi
|
||||
if [ "$listenermode" = "ON" ] ; then
|
||||
if [ -z "$tcp_port" ] && [ -z "$ws_port" ] && [ -z "$wss_port" ] && [ -z "$wg_port" ] ; then
|
||||
tcp_port="11010"
|
||||
ws_port="11011"
|
||||
wss_port="11012"
|
||||
wg_port="11011"
|
||||
fi
|
||||
if [ ! -z "$tcp_port" ] ; then
|
||||
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="$tcp_port"
|
||||
uci set firewall.easytier_tcp_udp.enabled="1"
|
||||
fi
|
||||
if [ ! -z "$wss_port" ] ; then
|
||||
uci -q delete firewall.easytier_wss
|
||||
uci set firewall.easytier_wss=rule
|
||||
uci set firewall.easytier_wss.name="easytier_wss"
|
||||
uci set firewall.easytier_wss.target="ACCEPT"
|
||||
uci set firewall.easytier_wss.src="wan"
|
||||
uci set firewall.easytier_wss.proto="all"
|
||||
uci set firewall.easytier_wss.dest_port="$wss_port"
|
||||
uci set firewall.easytier_wss.enabled="1"
|
||||
fi
|
||||
if [ ! -z "$ws_port" ] ; then
|
||||
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"
|
||||
fi
|
||||
if [ ! -z "$wg_port" ] ; then
|
||||
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"
|
||||
uci -q delete network.EasyTier >/dev/null 2>&1
|
||||
if [ -z "$(uci -q get network.EasyTier)" ]; then
|
||||
uci set network.EasyTier='interface'
|
||||
if [ -z "$ipaddr" ]; then
|
||||
uci set network.EasyTier.proto='none'
|
||||
else
|
||||
uci set network.EasyTier.proto='static'
|
||||
uci set network.EasyTier.ipaddr=$ipaddr
|
||||
uci set network.EasyTier.netmask='255.0.0.0'
|
||||
fi
|
||||
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'
|
||||
uci set firewall.easytierzone.input='ACCEPT'
|
||||
uci set firewall.easytierzone.output='ACCEPT'
|
||||
uci set firewall.easytierzone.forward='ACCEPT'
|
||||
uci set firewall.easytierzone.masq='1'
|
||||
uci set firewall.easytierzone.mtu_fix='1'
|
||||
uci set firewall.easytierzone.name='EasyTier'
|
||||
uci set firewall.easytierzone.network='EasyTier'
|
||||
fi
|
||||
uci set firewall.easytierfwlan=forwarding
|
||||
uci set firewall.easytierfwlan.dest='lan'
|
||||
uci set firewall.easytierfwlan.src='EasyTier'
|
||||
uci set firewall.easytierfwwan=forwarding
|
||||
uci set firewall.easytierfwwan.dest='wan'
|
||||
uci set firewall.easytierfwwan.src='EasyTier'
|
||||
uci set firewall.lanfweasytier=forwarding
|
||||
uci set firewall.lanfweasytier.dest='EasyTier'
|
||||
uci set firewall.lanfweasytier.src='lan'
|
||||
uci set firewall.wanfweasytier=forwarding
|
||||
uci set firewall.wanfweasytier.dest='EasyTier'
|
||||
uci set firewall.wanfweasytier.src='wan'
|
||||
[ -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
|
||||
[ -z "$proxy_network" ] || sysctl -w net.ipv4.ip_forward=1 >/dev/null 2>&1
|
||||
[ ! -z "$checkip" ] && check
|
||||
echo `date +%s` > /tmp/easytier_time
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load 'easytier'
|
||||
date_time=$(TZ='Asia/Shanghai' date +'%Y-%m-%d')
|
||||
ecmd=$(uci -q get easytier.@easytier[0].etcmd)
|
||||
if [ "$ecmd" = "etcmd" ] ; then
|
||||
ins_name=$(uci -q get easytier.@easytier[0].instance_name)
|
||||
else
|
||||
ins_name=$(cat /etc/easytier/config.toml | grep "instance_name =" | awk '{print $3}'| tr -d '" ')
|
||||
fi
|
||||
if [ ! -z "$ins_name" ] ; then
|
||||
touch /tmp/easytier-${ins_name}.${date_time}
|
||||
ln -sf /tmp/easytier-${ins_name}.${date_time} /tmp/easytier.log
|
||||
else
|
||||
touch /tmp/easytier-default.${date_time}
|
||||
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"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && 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" || cpucore="mipsel"
|
||||
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
|
||||
config_foreach start_et 'easytier'
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
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
|
||||
uci -q delete firewall.easytierfwwan >/dev/null 2>&1
|
||||
uci -q delete firewall.lanfweasytier >/dev/null 2>&1
|
||||
uci -q delete firewall.wanfweasytier >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_udp >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_tcp_udp >/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
|
||||
uci -q delete firewall.easytier_wireguard >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_socks5 >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_v6tcp >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_v6udp >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_v6ws >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_v6wss >/dev/null 2>&1
|
||||
uci -q delete firewall.easytier_v6wg >/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
|
||||
rm -rf /tmp/easytier-cli_peer-center /tmp/easytier-cli_vpn-portal /tmp/easytier_cmd /tmp/easytier-cli_node >/dev/null 2>&1
|
||||
rm -rf /tmp/easytier-*.* /tmp/easytier.log >/dev/null 2>&1
|
||||
rm -rf /tmp/easytiernew.tag /tmp/easytier.tag >/dev/null 2>&1
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') easytier : 停止运行" >>/tmp/easytier.log
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "eaytier"
|
||||
procd_add_interface_trigger "interface.*.up" wan /etc/init.d/easytier reload
|
||||
}
|
11
luci-app-easytier/root/etc/uci-defaults/luci-easytier
Normal file
11
luci-app-easytier/root/etc/uci-defaults/luci-easytier
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@easytier[-1]
|
||||
add ucitrack easytier
|
||||
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
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-easytier": {
|
||||
"description": "Grant UCI access for luci-app-easytier",
|
||||
"read": {
|
||||
"uci": [ "easytier" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "easytier" ]
|
||||
}
|
||||
}
|
||||
}
|
@ -10,11 +10,11 @@ include $(TOPDIR)/rules.mk
|
||||
PKG_ARCH_quickstart:=$(ARCH)
|
||||
|
||||
PKG_NAME:=quickstart
|
||||
PKG_VERSION:=0.9.6
|
||||
PKG_VERSION:=0.9.7
|
||||
PKG_RELEASE:=1
|
||||
PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://github.com/linkease/istore-packages/releases/download/prebuilt/
|
||||
PKG_HASH:=5c4d191d81651338f6560bbf78f5f2bb5729ba293844dfe24d3a41bd7aca6e8d
|
||||
PKG_HASH:=6c1d0b0fb13ad75ce2dad2d86b4a51ce925aa4c14551e95eecc4c65a08d57dbf
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-binary-$(PKG_VERSION)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user