Merge Lean's source

This commit is contained in:
CN_SZTL 2019-10-22 12:59:59 +08:00
commit 9ab41b53ea
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
11 changed files with 179 additions and 160 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-ssr-plus
PKG_VERSION:=1
PKG_RELEASE:=120
PKG_RELEASE:=121
PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \

View File

@ -13,7 +13,8 @@ function index()
entry({"admin", "services", "shadowsocksr", "client"},cbi("shadowsocksr/client"),_("SSR Client"), 10).leaf = true
entry({"admin", "services", "shadowsocksr", "servers"}, arcombine(cbi("shadowsocksr/servers"), cbi("shadowsocksr/client-config")),_("Severs Nodes"), 20).leaf = true
entry({"admin", "services", "shadowsocksr", "servers"}, arcombine(cbi("shadowsocksr/servers", {
autoapply=true}), cbi("shadowsocksr/client-config")),_("Severs Nodes"), 20).leaf = true
entry({"admin", "services", "shadowsocksr", "control"},cbi("shadowsocksr/control"),_("Access Control"), 30).leaf = true

View File

@ -9,6 +9,9 @@ uci:foreach("shadowsocksr", "servers", function(s)
server_count = server_count + 1
end)
local fs = require "nixio.fs"
local sys = require "luci.sys"
m = Map(shadowsocksr, translate("Servers subscription and manage"))
-- Server Subscribe
@ -31,17 +34,25 @@ o.rmempty = false
o = s:option(DynamicList, "subscribe_url", translate("Subscribe URL"))
o.rmempty = true
o = s:option(Button,"update_Sub",translate("Update Subscribe List"))
o.inputstyle = "reload"
o.description = translate("Update subscribe url list first")
o.write = function()
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers"))
end
o = s:option(Flag, "proxy", translate("Through proxy update"))
o.rmempty = false
o.description = translate("Through proxy update list, Not Recommended ")
o = s:option(Button,"update",translate("Update"))
o.inputstyle = "reload"
o.write = function()
luci.sys.call("bash /usr/share/shadowsocksr/subscribe.sh >>/tmp/ssrplus.log 2>&1")
o = s:option(Button,"update",translate("Update All Subscribe Severs"))
o.inputstyle = "apply"
o.write = function()
luci.sys.exec("bash /usr/share/shadowsocksr/subscribe.sh >>/tmp/ssrplus.log 2>&1")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers"))
end
o = s:option(Button,"delete",translate("Delete all severs"))
o.inputstyle = "reset"
o.description = string.format(translate("Server Count") .. ": %d", server_count)
@ -50,6 +61,7 @@ o.write = function()
uci:save("shadowsocksr")
luci.sys.call("uci commit shadowsocksr && /etc/init.d/shadowsocksr stop")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers"))
return
end
-- [[ Servers Manage ]]--
@ -106,4 +118,5 @@ o.template="shadowsocksr/ping"
o.width="10%"
m:append(Template("shadowsocksr/server_list"))
return m

View File

@ -450,7 +450,7 @@ msgid "Servers subscription and manage"
msgstr "服务器节点订阅与管理支持订阅和手动导入SSR链接"
msgid "Through proxy update list, Not Recommended"
msgstr "通过路由器自身代理更新订阅(不推荐)"
msgstr "通过路由器自身代理更新订阅"
msgid "LAN IP AC"
msgstr "LAN IP访问控制"
@ -465,7 +465,7 @@ msgid "Server failsafe auto swith settings"
msgstr "服务器节点故障自动切换设置"
msgid "Delete all severs"
msgstr "删除所有服务器"
msgstr "删除所有服务器节点"
msgid "Severs Nodes"
msgstr "服务器节点"
@ -520,3 +520,12 @@ msgstr "域名白名单"
msgid "Black Domain List"
msgstr "域名黑名单"
msgid "Update Subscribe List"
msgstr "更新订阅URL列表"
msgid "Update subscribe url list first"
msgstr "订阅服务器节点前请先更新订阅URL列表"
msgid "Update All Subscribe Severs"
msgstr "更新所有订阅服务器节点"

View File

@ -44,10 +44,10 @@ uci_get_by_type() {
add_cron()
{
sed -i '/ssrplus.log/d' $CRON_FILE
echo '0 1 * * 0 echo "" > /tmp/ssrplus.log' >> $CRON_FILE
echo '0 1 * * * echo "" > /tmp/ssrplus.log' >> $CRON_FILE
[ -n "$(grep -w "/usr/share/shadowsocksr/subscribe.sh" $CRON_FILE)" ] && sed -i '/\/usr\/share\/shadowsocksr\/subscribe.sh/d' $CRON_FILE
[ $(uci_get_by_type server_subscribe auto_update 0) -eq 1 ] && echo "0 $(uci_get_by_type server_subscribe auto_update_time) * * * /usr/share/shadowsocksr/subscribe.sh" >> $CRON_FILE
[ -z "$(grep -w "/usr/share/shadowsocksr/update.sh" $CRON_FILE)" ] && echo "0 5 * * 0 /usr/share/shadowsocksr/update.sh" >> $CRON_FILE
[ -z "$(grep -w "/usr/share/shadowsocksr/update.sh" $CRON_FILE)" ] && echo "0 5 * * * /usr/share/shadowsocksr/update.sh" >> $CRON_FILE
crontab $CRON_FILE
}

View File

@ -6,10 +6,10 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for V2ray Server
LUCI_DEPENDS:=+libsodium +luci-lib-jsonc +v2ray
LUCI_DEPENDS:=+v2ray
LUCI_PKGARCH:=all
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_RELEASE:=5
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -1,65 +1,77 @@
local ucursor = require "luci.model.uci".cursor()
local json = require "luci.jsonc"
local server_section = arg[1]
local server = ucursor:get_all("v2ray_server", server_section)
local e=require"luci.model.uci".cursor()
local a=require"luci.jsonc"
local t=arg[1]
local e=e:get_all("v2ray_server",t)
local v2ray = {
local e={
log = {
--error = "/var/log/v2ray.log",
loglevel = "warning"
},
-- 传入连接
inbound = {
port = tonumber(server.port),
protocol = server.protocol,
settings = {
clients = {
{
id = server.VMess_id,
alterId = tonumber(server.VMess_alterId),
level = tonumber(server.VMess_level)
loglevel = "warning"
},
inbound = {
port = tonumber(e.port),
protocol = e.protocol,
(e.protocol == 'vmess') and {
settings = {
clients = {
{
id = e.VMess_id,
alterId = tonumber(e.VMess_alterId),
level = tonumber(e.VMess_level)
}
}
}
},
-- 底层传输配置
streamSettings = {
network = server.transport,
security = (server.tls == '1') and "tls" or "none",
kcpSettings = (server.transport == "mkcp") and {
mtu = tonumber(server.mkcp_mtu),
tti = tonumber(server.mkcp_tti),
uplinkCapacity = tonumber(server.mkcp_uplinkCapacity),
downlinkCapacity = tonumber(server.mkcp_downlinkCapacity),
congestion = (server.mkcp_congestion == "1") and true or false,
readBufferSize = tonumber(server.mkcp_readBufferSize),
writeBufferSize = tonumber(server.mkcp_writeBufferSize),
header = {
type = server.mkcp_guise
(e.protocol == 'socks') and {
settings = {
auth= "password",
accounts = {
{
user = e.Socks_user,
pass = e.Socks_pass
}
}
} or nil,
httpSettings = (server.transport == "h2") and {
path = server.h2_path,
host = server.h2_host,
} or nil,
quicSettings = (server.transport == "quic") and {
security = server.quic_security,
key = server.quic_key,
header = {
type = server.quic_guise
}
},
streamSettings = {
network = e.transport,
security = (e.tls == '1') and "tls" or "none",
kcpSettings = (e.transport == "mkcp") and {
mtu = tonumber(e.mkcp_mtu),
tti = tonumber(e.mkcp_tti),
uplinkCapacity = tonumber(e.mkcp_uplinkCapacity),
downlinkCapacity = tonumber(e.mkcp_downlinkCapacity),
congestion = (e.mkcp_congestion == "1") and true or false,
readBufferSize = tonumber(e.mkcp_readBufferSize),
writeBufferSize = tonumber(e.mkcp_writeBufferSize),
header = {
type = e.mkcp_guise
}
}
} or nil
or nil,
httpSettings = (e.transport == "h2") and {
path = e.h2_path,
host = e.h2_host,
}
or nil,
quicSettings = (e.transport == "quic") and {
security = e.quic_security,
key = e.quic_key,
header = {
type = e.quic_guise
}
}
or nil
}
},
outbound = {
protocol = "freedom"
},
outboundDetour = {
{
protocol = "blackhole",
tag = "blocked"
}
}
},
-- 传出连接
outbound = {
protocol = "freedom"
},
-- 额外传出连接
outboundDetour = {
{
protocol = "blackhole",
tag = "blocked"
}
}
}
print(json.stringify(v2ray,1))
print(a.stringify(e,1))

View File

@ -1,8 +1,7 @@
local i = "v2ray_server"
local d = require "luci.dispatcher"
local i="v2ray_server"
local n=require"luci.dispatcher"
local a,t,e
local header_type={
local o={
"none",
"srtp",
"utp",
@ -10,101 +9,97 @@ local header_type={
"dtls",
"wireguard",
}
a=Map(i,"V2ray "..translate("Server Config"))
a.redirect=d.build_url("admin","vpn","v2ray_server")
a.redirect=n.build_url("admin","vpn","v2ray_server")
t=a:section(NamedSection,arg[1],"user","")
t.addremove=false
t.dynamic=false
e=t:option(Flag, "enable", translate("Enable"))
e.default = "1"
e.rmempty = false
e=t:option(Flag,"enable",translate("Enable"))
e.default="1"
e.rmempty=false
e=t:option(Value,"remarks",translate("Remarks"))
e.default=translate("Remarks")
e.rmempty=false
e.rmempty=false
e=t:option(Value,"port",translate("Port"))
e.datatype="port"
e.rmempty=false
e.default=10086
e=t:option(ListValue,"protocol",translate("Protocol"))
e:value("vmess",translate("Vmess"))
e:value("socks",translate("Socks5"))
e=t:option(Value,"VMess_id",translate("ID"))
e.default = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
e.rmempty=false
e.default=luci.sys.exec("cat /proc/sys/kernel/random/uuid")
e.rmempty=true
e:depends("protocol","vmess")
e=t:option(Value,"VMess_alterId",translate("Alter ID"))
e.default=16
e.rmempty=false
e.rmempty=true
e:depends("protocol","vmess")
e=t:option(Value,"Socks_user",translate("User name"))
e.default="lean"
e.rmempty=true
e:depends("protocol","socks")
e=t:option(Value,"Socks_pass",translate("Password"))
e.default="password"
e.rmempty=true
e.password=true
e:depends("protocol","socks")
e=t:option(Value,"VMess_level",translate("User Level"))
e.default=1
e=t:option(ListValue,"transport",translate("Transport"))
e.default=tcp
e:value("tcp","TCP")
e:value("mkcp", "mKCP")
e:value("quic", "QUIC")
e:value("mkcp","mKCP")
e:value("quic","QUIC")
e:depends("protocol","vmess")
-- [[ TCP部分 ]]--
e=t:option(ListValue,"tcp_guise",translate("Camouflage Type"))
e:depends("transport","tcp")
e:value("none","none")
e:value("http","http")
e.default=none
-- TCP伪装
e = t:option(ListValue, "tcp_guise", translate("Camouflage Type"))
e:depends("transport", "tcp")
e:value("none", "none")
e:value("http", "http")
-- HTTP域名
e = t:option(DynamicList, "tcp_guise_http_host", translate("HTTP Host"))
e:depends("tcp_guise", "http")
-- HTTP路径
e = t:option(DynamicList, "tcp_guise_http_path", translate("HTTP Path"))
e:depends("tcp_guise", "http")
-- [[ mKCP部分 ]]--
e=t:option(DynamicList,"tcp_guise_http_host",translate("HTTP Host"))
e:depends("tcp_guise","http")
e=t:option(DynamicList,"tcp_guise_http_path",translate("HTTP Path"))
e:depends("tcp_guise","http")
e=t:option(ListValue,"mkcp_guise",translate("Camouflage Type"))
for a,t in ipairs(header_type)do e:value(t)end
for a,t in ipairs(o)do e:value(t)end
e:depends("transport","mkcp")
e=t:option(Value,"mkcp_mtu",translate("KCP MTU"))
e:depends("transport","mkcp")
e=t:option(Value,"mkcp_tti",translate("KCP TTI"))
e:depends("transport","mkcp")
e=t:option(Value,"mkcp_uplinkCapacity",translate("KCP uplinkCapacity"))
e:depends("transport","mkcp")
e=t:option(Value,"mkcp_downlinkCapacity",translate("KCP downlinkCapacity"))
e:depends("transport","mkcp")
e=t:option(Flag,"mkcp_congestion",translate("KCP Congestion"))
e:depends("transport","mkcp")
e=t:option(Value,"mkcp_readBufferSize",translate("KCP readBufferSize"))
e:depends("transport","mkcp")
e=t:option(Value,"mkcp_writeBufferSize",translate("KCP writeBufferSize"))
e:depends("transport","mkcp")
-- [[ QUIC部分 ]]--
e=t:option(ListValue,"quic_security",translate("Encrypt Method"))
e:value("none")
e:value("aes-128-gcm")
e:value("chacha20-poly1305")
e:depends("transport","quic")
e=t:option(Value,"quic_key",translate("Encrypt Method")..translate("Key"))
e:depends("transport","quic")
e=t:option(ListValue,"quic_guise",translate("Camouflage Type"))
for a,t in ipairs(header_type)do e:value(t)end
for a,t in ipairs(o)do e:value(t)end
e:depends("transport","quic")
return a

View File

@ -1,56 +1,44 @@
local o = require "luci.dispatcher"
local fs = require "nixio.fs"
local sys = require "luci.sys"
local cursor = luci.model.uci.cursor()
local appname = "v2ray_server"
local a,t,e
local i=require"luci.dispatcher"
local e=require"nixio.fs"
local e=require"luci.sys"
local e=luci.model.uci.cursor()
local o="v2ray_server"
local a,e,t
a=Map(appname, translate("V2ray Server"))
a=Map(o,translate("V2ray Server"))
e=a:section(TypedSection,"global",translate("Global Setting"))
e.anonymous=true
e.addremove=false
t=e:option(Flag,"enable",translate("Enable"))
t.rmempty=false
t=a:section(TypedSection,"global",translate("Global Settings"))
t.anonymous=true
t.addremove=false
e=a:section(TypedSection,"user",translate("Server Setting"))
e.anonymous=true
e.addremove=true
e.template="cbi/tblsection"
e.extedit=i.build_url("admin","vpn",o,"config","%s")
e=t:option(Flag,"enable",translate("Enable"))
e.rmempty=false
t:append(Template("v2ray_server/v2ray"))
t=a:section(TypedSection,"user",translate("Users Manager"))
t.anonymous=true
t.addremove=true
t.template="cbi/tblsection"
t.extedit=o.build_url("admin","vpn",appname,"config","%s")
function t.create(e,t)
local e=TypedSection.create(e,t)
luci.http.redirect(o.build_url("admin","vpn",appname,"config",e))
function e.create(t,e)
local e=TypedSection.create(t,e)
luci.http.redirect(i.build_url("admin","vpn",o,"config",e))
end
function t.remove(t,a)
t.map.proceed=true
t.map:del(a)
luci.http.redirect(o.build_url("admin","vpn",appname))
function e.remove(e,a)
e.map.proceed=true
e.map:del(a)
luci.http.redirect(i.build_url("admin","vpn",o))
end
e=t:option(Flag, "enable", translate("Enable"))
e.width="5%"
e.rmempty = false
e=t:option(DummyValue,"status",translate("Status"))
e.template="v2ray_server/users_status"
e.value=translate("Collecting data...")
e=t:option(DummyValue,"remarks",translate("Remarks"))
e.width="15%"
e=t:option(DummyValue,"port",translate("Port"))
e.width="10%"
e=t:option(DummyValue,"protocol",translate("Protocol"))
e.width="15%"
e=t:option(DummyValue,"VMess_id",translate("ID"))
e.width="35%"
t=e:option(Flag,"enable",translate("Enable"))
t.width="5%"
t.rmempty=false
t=e:option(DummyValue,"status",translate("Status"))
t.template="v2ray_server/users_status"
t.value=translate("Collecting data...")
t=e:option(DummyValue,"remarks",translate("Remarks"))
t.width="15%"
t=e:option(DummyValue,"port",translate("Port"))
t=e:option(DummyValue,"protocol",translate("Protocol"))
a:append(Template("v2ray_server/users_list_status"))

View File

@ -12,7 +12,8 @@ gen_v2ray_config_file() {
config_get remarks $1 remarks
config_get port $1 port
lua /usr/lib/lua/luci/model/cbi/v2ray_server/api/genv2rayconfig.lua $1 > $CONFIG_PATH/$1.json
/usr/bin/v2ray/v2ray -config $CONFIG_PATH/$1.json >/dev/null 2>&1 &
[ -f /var/v2server ] || cp -a /usr/bin/v2ray/v2ray /var/v2server
/var/v2server -config $CONFIG_PATH/$1.json >/dev/null 2>&1 &
}
start_v2ray_server() {

View File

@ -21,7 +21,7 @@ include $(INCLUDE_DIR)/target.mk
DEFAULT_PACKAGES += partx-utils mkf2fs fdisk e2fsprogs wpad kmod-usb-hid \
kmod-ath5k kmod-ath9k kmod-ath9k-htc kmod-ath10k kmod-rt2800-usb kmod-e1000e kmod-igb kmod-igbvf kmod-ixgbe kmod-pcnet32 kmod-tulip kmod-vmxnet3 kmod-i40e kmod-i40evf kmod-fs-f2fs \
htop lm-sensors autocore automount autosamba luci-app-zerotier luci-app-ipsec-vpnd luci-app-pptp-server luci-proto-bonding luci-app-zerotier luci-app-unblockmusic luci-app-transmission luci-app-docker \
htop lm-sensors autocore automount autosamba luci-app-zerotier luci-app-ipsec-vpnd luci-app-pptp-server luci-proto-bonding luci-app-zerotier luci-app-unblockmusic luci-app-transmission luci-app-docker luci-app-v2ray-server \
ath10k-firmware-qca988x ath10k-firmware-qca9888 ath10k-firmware-qca9984 brcmfmac-firmware-43602a1-pcie kmod-crypto-misc \
alsa-utils kmod-ac97 kmod-sound-hda-core kmod-sound-hda-codec-realtek kmod-sound-hda-codec-via kmod-sound-via82xx kmod-usb-audio \
kmod-usb-net kmod-usb-net-asix kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8150 kmod-usb-net-rtl8152 \