diff --git a/package/lean/luci-app-v2ray-server/Makefile b/package/lean/luci-app-v2ray-server/Makefile index f6d2d6fe9..5496c4c7d 100644 --- a/package/lean/luci-app-v2ray-server/Makefile +++ b/package/lean/luci-app-v2ray-server/Makefile @@ -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 diff --git a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua index f1d44a044..2f4996a01 100644 --- a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua +++ b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua @@ -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)) \ No newline at end of file + +print(a.stringify(e,1)) \ No newline at end of file diff --git a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua index 8b826b96d..80a2570d4 100644 --- a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua +++ b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua @@ -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 diff --git a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/index.lua b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/index.lua index be1682a77..b6fc41e06 100644 --- a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/index.lua +++ b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/index.lua @@ -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")) diff --git a/package/lean/luci-app-v2ray-server/root/etc/init.d/v2ray_server b/package/lean/luci-app-v2ray-server/root/etc/init.d/v2ray_server index 1d9f14fb9..ba4f90653 100755 --- a/package/lean/luci-app-v2ray-server/root/etc/init.d/v2ray_server +++ b/package/lean/luci-app-v2ray-server/root/etc/init.d/v2ray_server @@ -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() { diff --git a/target/linux/x86/Makefile b/target/linux/x86/Makefile index d23d0fa0a..259cecd0e 100644 --- a/target/linux/x86/Makefile +++ b/target/linux/x86/Makefile @@ -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 \