mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-19 14:13:30 +00:00
add V2Ray and SSR server in luci ssr plus
This commit is contained in:
parent
2dc71cc4ff
commit
2121e97d32
@ -9,7 +9,7 @@ LUCI_TITLE:=LuCI support for SSR Plus
|
||||
LUCI_DEPENDS:=+shadowsocksr-libev-alt +shadowsocks-libev-ss-redir +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +bash +pdnsd-alt +wget
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=36
|
||||
PKG_RELEASE:=38
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
@ -8,6 +8,7 @@ local ipkg = require("luci.model.ipkg")
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
local sid = arg[1]
|
||||
local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
|
||||
|
||||
local function isKcptun(file)
|
||||
if not fs.access(file, "rwx", "rx", "rx") then
|
||||
@ -151,6 +152,8 @@ o.rmempty = false
|
||||
o = s:option(Value, "password", translate("Password"))
|
||||
o.password = true
|
||||
o.rmempty = false
|
||||
o:depends("type", "ssr")
|
||||
o:depends("type", "ss")
|
||||
|
||||
o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
|
||||
for _, v in ipairs(encrypt_methods) do o:value(v) end
|
||||
@ -188,6 +191,7 @@ o:depends("type", "v2ray")
|
||||
-- VmessId
|
||||
o = s:option(Value, "vmess_id", translate("VmessId"))
|
||||
o.rmempty = false
|
||||
o.default = uuid
|
||||
o:depends("type", "v2ray")
|
||||
|
||||
-- 加密方式
|
||||
@ -308,6 +312,8 @@ o:depends("type", "v2ray")
|
||||
o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
|
||||
o.rmempty = false
|
||||
o.default = "0"
|
||||
o:depends("type", "ssr")
|
||||
o:depends("type", "ss")
|
||||
|
||||
o = s:option(Flag, "switch_enable", translate("Enable Auto Switch"))
|
||||
o.rmempty = false
|
||||
@ -322,6 +328,8 @@ if nixio.fs.access("/usr/bin/ssr-kcptun") then
|
||||
|
||||
kcp_enable = s:option(Flag, "kcp_enable", translate("KcpTun Enable"), translate("bin:/usr/bin/ssr-kcptun"))
|
||||
kcp_enable.rmempty = false
|
||||
kcp_enable:depends("type", "ssr")
|
||||
kcp_enable:depends("type", "ss")
|
||||
|
||||
o = s:option(Value, "kcp_port", translate("KcpTun Port"))
|
||||
o.datatype = "port"
|
||||
@ -339,12 +347,18 @@ function o.validate(self, value, section)
|
||||
|
||||
return value
|
||||
end
|
||||
kcp_enable:depends("type", "ssr")
|
||||
kcp_enable:depends("type", "ss")
|
||||
|
||||
o = s:option(Value, "kcp_password", translate("KcpTun Password"))
|
||||
o.password = true
|
||||
kcp_enable:depends("type", "ssr")
|
||||
kcp_enable:depends("type", "ss")
|
||||
|
||||
o = s:option(Value, "kcp_param", translate("KcpTun Param"))
|
||||
o.default = "--nocomp"
|
||||
kcp_enable:depends("type", "ssr")
|
||||
kcp_enable:depends("type", "ss")
|
||||
|
||||
end
|
||||
|
||||
|
@ -369,7 +369,7 @@ msgid "GFW List"
|
||||
msgstr "GFW列表"
|
||||
|
||||
msgid "ShadowSocksR Plus+ Settings"
|
||||
msgstr "ShadowSocksR Plus+ 设置"
|
||||
msgstr "ShadowSocksR Plus+ 设置(支持SS/SSR/V2RAY)"
|
||||
|
||||
msgid "Main Server"
|
||||
msgstr "主服务器"
|
||||
|
@ -2,6 +2,7 @@
|
||||
#
|
||||
# Copyright (C) 2017 openwrt-ssr
|
||||
# Copyright (C) 2017 yushi studio <ywb94@qq.com>
|
||||
# Copyright (C) 2018 lean <coolsnowwolf@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
@ -119,6 +120,8 @@ EOF
|
||||
"fast_open": $fastopen
|
||||
}
|
||||
EOF
|
||||
elif [ "$stype" == "v2ray" ] ;then
|
||||
lua /usr/share/shadowsocksr/genv2config.lua $GLOBAL_SERVER tcp > /var/etc/v2-ssr-retcp.json
|
||||
fi
|
||||
}
|
||||
|
||||
@ -147,7 +150,7 @@ start_rules() {
|
||||
|
||||
kcp_server=$server
|
||||
|
||||
local kcp_enable=$(uci_get_by_name $GLOBAL_SERVER kcp_enable)
|
||||
local kcp_enable=$(uci_get_by_name $GLOBAL_SERVER kcp_enable 0)
|
||||
if [ $kcp_enable = "1" ] ;then
|
||||
kcp_flag=1
|
||||
fi
|
||||
@ -256,7 +259,7 @@ start_redir() {
|
||||
esac
|
||||
|
||||
#deal kcp
|
||||
local kcp_enable=$(uci_get_by_name $GLOBAL_SERVER kcp_enable)
|
||||
local kcp_enable=$(uci_get_by_name $GLOBAL_SERVER kcp_enable 0)
|
||||
if [ $kcp_enable = "1" ] ;then
|
||||
[ ! -f "/usr/bin/ssr-kcptun" ] && return 1
|
||||
|
||||
@ -280,7 +283,7 @@ start_redir() {
|
||||
elif [ "$stype" == "ssr" ] ;then
|
||||
sscmd="/usr/bin/ssr-redir"
|
||||
elif [ "$stype" == "v2ray" ] ;then
|
||||
sscmd="/usr/bin/v2ray"
|
||||
sscmd="/usr/bin/v2ray/v2ray"
|
||||
fi
|
||||
|
||||
local utype=$(uci_get_by_name $UDP_RELAY_SERVER type)
|
||||
@ -289,17 +292,23 @@ start_redir() {
|
||||
elif [ "$utype" == "ssr" ] ;then
|
||||
ucmd="/usr/bin/ssr-redir"
|
||||
elif [ "$utype" == "v2ray" ] ;then
|
||||
ucmd="/usr/bin/v2ray"
|
||||
ucmd="/usr/bin/v2ray/v2ray"
|
||||
fi
|
||||
|
||||
redir_tcp=1
|
||||
local last_config_file=$CONFIG_FILE
|
||||
local pid_file="/var/run/ssr-retcp.pid"
|
||||
$sscmd \
|
||||
-c $CONFIG_FILE $ARG_OTA \
|
||||
-f /var/run/ssr-retcp.pid
|
||||
|
||||
if [ "$stype" == "ss" -o "$stype" == "ssr" ] ;then
|
||||
local last_config_file=$CONFIG_FILE
|
||||
local pid_file="/var/run/ssr-retcp.pid"
|
||||
$sscmd \
|
||||
-c $CONFIG_FILE $ARG_OTA \
|
||||
-f /var/run/ssr-retcp.pid
|
||||
elif [ "$stype" == "v2ray" ] ;then
|
||||
$sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 &
|
||||
fi
|
||||
|
||||
if [ "$ARG_UDP" = "-U" ]; then
|
||||
if [ "$utype" == "ss" -o "$utype" == "ssr" ] ;then
|
||||
case "$(uci_get_by_name $UDP_RELAY_SERVER auth_enable)" in
|
||||
1|on|true|yes|enabled) ARG_OTA="-A";;
|
||||
*) ARG_OTA="";;
|
||||
@ -310,9 +319,15 @@ start_redir() {
|
||||
redir_udp=1
|
||||
$ucmd \
|
||||
-c $last_config_file $ARG_OTA $ARG_UDP \
|
||||
-f $pid_file
|
||||
-f $pid_file
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$utype" == "v2ray" ] ; then
|
||||
lua /usr/share/shadowsocksr/genv2config.lua $UDP_RELAY_SERVER udp > /var/etc/v2-ssr-reudp.json
|
||||
$ucmd -config /var/etc/v2-ssr-reudp.json >/dev/null 2>&1 &
|
||||
fi
|
||||
|
||||
#deal with dns
|
||||
|
||||
if [ "$(uci_get_by_type global pdnsd_enable)" = "1" ] ;then
|
||||
@ -471,6 +486,7 @@ stop() {
|
||||
fi
|
||||
killall -q -9 ss-redir
|
||||
killall -q -9 ssr-redir
|
||||
killall -q -9 v2ray
|
||||
killall -q -9 ssr-server
|
||||
killall -q -9 ssr-kcptun
|
||||
killall -q -9 ssr-local
|
||||
|
@ -0,0 +1,78 @@
|
||||
local ucursor = require "luci.model.uci"
|
||||
local json = require "luci.jsonc"
|
||||
local server_section = arg[1]
|
||||
local proto = arg[2]
|
||||
|
||||
local server = ucursor:get_all("shadowsocksr", server_section)
|
||||
|
||||
local v2ray = {
|
||||
-- 传入连接
|
||||
inbound = {
|
||||
port = 1234,
|
||||
protocol = "dokodemo-door",
|
||||
settings = {
|
||||
network = proto,
|
||||
followRedirect = true
|
||||
},
|
||||
sniffing = {
|
||||
enabled = true,
|
||||
destOverride = { "http", "tls" }
|
||||
}
|
||||
},
|
||||
-- 传出连接
|
||||
outbound = {
|
||||
protocol = "vmess",
|
||||
settings = {
|
||||
vnext = {
|
||||
{
|
||||
address = server.server,
|
||||
port = tonumber(server.server_port),
|
||||
users = {
|
||||
{
|
||||
id = server.vmess_id,
|
||||
alterId = tonumber(server.alter_id),
|
||||
security = server.security
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
-- 底层传输配置
|
||||
streamSettings = {
|
||||
network = server.transport,
|
||||
security = (server.tls == '1') and "tls" or "none",
|
||||
kcpSettings = (server.transport == "kcp") and {
|
||||
mtu = tonumber(server.mtu),
|
||||
tti = tonumber(server.tti),
|
||||
uplinkCapacity = tonumber(server.uplink_capacity),
|
||||
downlinkCapacity = tonumber(server.downlink_capacity),
|
||||
congestion = (server.congestion == "1") and true or false,
|
||||
readBufferSize = tonumber(server.read_buffer_size),
|
||||
writeBufferSize = tonumber(server.write_buffer_size),
|
||||
header = {
|
||||
type = server.kcp_guise
|
||||
}
|
||||
} or nil,
|
||||
wsSettings = (server.transport == "ws") and {
|
||||
path = server.ws_path,
|
||||
headers = (server.ws_host ~= nil) and {
|
||||
Host = server.ws_host
|
||||
} or nil,
|
||||
} or nil,
|
||||
httpSettings = (server.transport == "h2") and {
|
||||
path = server.h2_path,
|
||||
host = server.h2_host,
|
||||
} or nil
|
||||
}
|
||||
},
|
||||
|
||||
-- 额外传出连接
|
||||
outboundDetour = {
|
||||
{
|
||||
protocol = "freedom",
|
||||
tag = "direct",
|
||||
settings = { keep = "" }
|
||||
}
|
||||
}
|
||||
}
|
||||
print(json.stringify(v2ray))
|
@ -39,7 +39,7 @@ define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=V2Ray is a cross-platform proxy software
|
||||
DEPENDS:=
|
||||
DEPENDS:=+ca-certificates
|
||||
URL:=https://github.com/v2ray/v2ray-core
|
||||
endef
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user