luci-app-v2ray-server: fix socks user and pass auth

This commit is contained in:
LEAN-ESX 2019-10-22 09:18:28 -07:00
parent 67ed2cf85c
commit d24f24016b
3 changed files with 79 additions and 74 deletions

View File

@ -9,7 +9,7 @@ LUCI_TITLE:=LuCI support for V2ray Server
LUCI_DEPENDS:=+v2ray LUCI_DEPENDS:=+v2ray
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
PKG_VERSION:=1.0 PKG_VERSION:=1.0
PKG_RELEASE:=5 PKG_RELEASE:=6
include $(TOPDIR)/feeds/luci/luci.mk include $(TOPDIR)/feeds/luci/luci.mk

View File

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

View File

@ -31,7 +31,7 @@ e.default=10086
e=t:option(ListValue,"protocol",translate("Protocol")) e=t:option(ListValue,"protocol",translate("Protocol"))
e:value("vmess",translate("Vmess")) e:value("vmess",translate("Vmess"))
e:value("socks",translate("Socks5")) e:value("socks",translate("Socks"))
e=t:option(Value,"VMess_id",translate("ID")) e=t:option(Value,"VMess_id",translate("ID"))
e.default=luci.sys.exec("cat /proc/sys/kernel/random/uuid") e.default=luci.sys.exec("cat /proc/sys/kernel/random/uuid")