diff --git a/luci-app-xray/core/root/usr/share/xray/common/stream.mjs b/luci-app-xray/core/root/usr/share/xray/common/stream.mjs index 043dcaec6..0b9ba36e4 100644 --- a/luci-app-xray/core/root/usr/share/xray/common/stream.mjs +++ b/luci-app-xray/core/root/usr/share/xray/common/stream.mjs @@ -131,6 +131,13 @@ function stream_quic(server) { return null; } +export function port_array(i) { + if (type(i) === 'array') { + return map(i, v => int(v)); + } + return [int(i)]; +}; + export function stream_settings(server, protocol, tag) { const security = server[protocol + "_tls"]; let tlsSettings = null; diff --git a/luci-app-xray/core/root/usr/share/xray/protocol/http.mjs b/luci-app-xray/core/root/usr/share/xray/protocol/http.mjs index b340243ec..f00cd23dd 100644 --- a/luci-app-xray/core/root/usr/share/xray/protocol/http.mjs +++ b/luci-app-xray/core/root/usr/share/xray/protocol/http.mjs @@ -1,6 +1,6 @@ "use strict"; -import { stream_settings } from "../common/stream.mjs"; +import { port_array, stream_settings } from "../common/stream.mjs"; export function http_outbound(server, tag) { const stream_settings_object = stream_settings(server, "http", tag); @@ -20,13 +20,13 @@ export function http_outbound(server, tag) { protocol: "http", tag: tag, settings: { - servers: [ - { + servers: map(port_array(server["server_port"]), function (v) { + return { address: server["server"], - port: int(server["server_port"]), + port: v, users: users - } - ] + }; + }) }, streamSettings: stream_settings_result }, diff --git a/luci-app-xray/core/root/usr/share/xray/protocol/shadowsocks.mjs b/luci-app-xray/core/root/usr/share/xray/protocol/shadowsocks.mjs index 12cdda287..e91246053 100644 --- a/luci-app-xray/core/root/usr/share/xray/protocol/shadowsocks.mjs +++ b/luci-app-xray/core/root/usr/share/xray/protocol/shadowsocks.mjs @@ -1,6 +1,6 @@ "use strict"; -import { stream_settings } from "../common/stream.mjs"; +import { port_array, stream_settings } from "../common/stream.mjs"; export function shadowsocks_outbound(server, tag) { const stream_settings_object = stream_settings(server, "shadowsocks", tag); @@ -11,16 +11,16 @@ export function shadowsocks_outbound(server, tag) { protocol: "shadowsocks", tag: tag, settings: { - servers: [ - { + servers: map(port_array(server["server_port"]), function (v) { + return { address: server["server"], - port: int(server["server_port"]), + port: v, email: server["username"], password: server["password"], method: server["shadowsocks_security"], uot: server["shadowsocks_udp_over_tcp"] == '1' - } - ] + }; + }) }, streamSettings: stream_settings_result }, diff --git a/luci-app-xray/core/root/usr/share/xray/protocol/socks.mjs b/luci-app-xray/core/root/usr/share/xray/protocol/socks.mjs index 4d11a696c..a6563d51d 100644 --- a/luci-app-xray/core/root/usr/share/xray/protocol/socks.mjs +++ b/luci-app-xray/core/root/usr/share/xray/protocol/socks.mjs @@ -1,6 +1,6 @@ "use strict"; -import { stream_settings } from "../common/stream.mjs"; +import { port_array, stream_settings } from "../common/stream.mjs"; export function socks_outbound(server, tag) { const stream_settings_object = stream_settings(server, "socks", tag); @@ -20,13 +20,13 @@ export function socks_outbound(server, tag) { protocol: "socks", tag: tag, settings: { - servers: [ - { + servers: map(port_array(server["server_port"]), function (v) { + return { address: server["server"], - port: int(server["server_port"]), + port: v, users: users } - ] + }) }, streamSettings: stream_settings_result }, diff --git a/luci-app-xray/core/root/usr/share/xray/protocol/trojan.mjs b/luci-app-xray/core/root/usr/share/xray/protocol/trojan.mjs index 9fa995723..e3a93ca82 100644 --- a/luci-app-xray/core/root/usr/share/xray/protocol/trojan.mjs +++ b/luci-app-xray/core/root/usr/share/xray/protocol/trojan.mjs @@ -1,6 +1,6 @@ "use strict"; -import { stream_settings } from "../common/stream.mjs"; +import { port_array, stream_settings } from "../common/stream.mjs"; import { fallbacks, tls_inbound_settings } from "../common/tls.mjs"; function trojan_inbound_user(k) { @@ -19,14 +19,14 @@ export function trojan_outbound(server, tag) { protocol: "trojan", tag: tag, settings: { - servers: [ - { + servers: map(port_array(server["server_port"]), function (v) { + return { address: server["server"], - port: int(server["server_port"]), + port: v, email: server["username"], password: server["password"] - } - ] + }; + }) }, streamSettings: stream_settings_result }, diff --git a/luci-app-xray/core/root/usr/share/xray/protocol/vless.mjs b/luci-app-xray/core/root/usr/share/xray/protocol/vless.mjs index e551bb012..eea7d9bc4 100644 --- a/luci-app-xray/core/root/usr/share/xray/protocol/vless.mjs +++ b/luci-app-xray/core/root/usr/share/xray/protocol/vless.mjs @@ -1,6 +1,6 @@ "use strict"; -import { stream_settings } from "../common/stream.mjs"; +import { port_array, stream_settings } from "../common/stream.mjs"; import { fallbacks, reality_inbound_settings, tls_inbound_settings } from "../common/tls.mjs"; function vless_inbound_user(k, flow) { @@ -29,10 +29,10 @@ export function vless_outbound(server, tag) { protocol: "vless", tag: tag, settings: { - vnext: [ - { + vnext: map(port_array(server["server_port"]), function (v) { + return { address: server["server"], - port: int(server["server_port"]), + port: v, users: [ { email: server["username"], @@ -42,7 +42,7 @@ export function vless_outbound(server, tag) { } ] } - ] + }) }, streamSettings: stream_settings_result }, diff --git a/luci-app-xray/core/root/usr/share/xray/protocol/vmess.mjs b/luci-app-xray/core/root/usr/share/xray/protocol/vmess.mjs index b2c990c7f..6603d2fef 100644 --- a/luci-app-xray/core/root/usr/share/xray/protocol/vmess.mjs +++ b/luci-app-xray/core/root/usr/share/xray/protocol/vmess.mjs @@ -1,6 +1,6 @@ "use strict"; -import { stream_settings } from "../common/stream.mjs"; +import { port_array, stream_settings } from "../common/stream.mjs"; export function vmess_outbound(server, tag) { const stream_settings_object = stream_settings(server, "vmess", tag); @@ -11,10 +11,10 @@ export function vmess_outbound(server, tag) { protocol: "vmess", tag: tag, settings: { - vnext: [ - { + vnext: map(port_array(server["server_port"]), function (v) { + return { address: server["server"], - port: int(server["server_port"]), + port: v, users: [ { email: server["username"], @@ -23,8 +23,8 @@ export function vmess_outbound(server, tag) { security: server["vmess_security"] } ] - } - ] + }; + }) }, streamSettings: stream_settings_result }, diff --git a/luci-app-xray/core/root/www/luci-static/resources/view/xray/core.js b/luci-app-xray/core/root/www/luci-static/resources/view/xray/core.js index fe3f83153..cea135f1c 100644 --- a/luci-app-xray/core/root/www/luci-static/resources/view/xray/core.js +++ b/luci-app-xray/core/root/www/luci-static/resources/view/xray/core.js @@ -184,6 +184,7 @@ return view.extend({ ss.addremove = true; ss.tab('general', _('General Settings')); + ss.nodescriptions = true; o = ss.taboption('general', form.Value, "alias", _("Alias (optional)")); o.optional = true; @@ -192,15 +193,15 @@ return view.extend({ o.datatype = 'host'; o.rmempty = false; - o = ss.taboption('general', form.Value, 'server_port', _('Server Port')); + o = ss.taboption('general', form.DynamicList, 'server_port', _('Server Port')); o.datatype = 'port'; o.rmempty = false; + o.modalonly = true; o = ss.taboption('general', form.Value, 'username', _('Email / Username'), _('Optional; username for SOCKS / HTTP outbound, email for other outbound.')); o.modalonly = true; o = ss.taboption('general', form.Value, 'password', _('UserId / Password'), _('Fill user_id for vmess / VLESS, or password for other outbound (also supports Xray UUID Mapping)')); - o.modalonly = true; o.rmempty = false; ss.tab('resolving', _("Server Hostname Resolving"));