diff --git a/core/root/usr/share/xray/protocol/socks.mjs b/core/root/usr/share/xray/protocol/socks.mjs index a6563d51..032ec118 100644 --- a/core/root/usr/share/xray/protocol/socks.mjs +++ b/core/root/usr/share/xray/protocol/socks.mjs @@ -25,7 +25,7 @@ export function socks_outbound(server, tag) { address: server["server"], port: v, users: users - } + }; }) }, streamSettings: stream_settings_result diff --git a/core/root/usr/share/xray/protocol/vless.mjs b/core/root/usr/share/xray/protocol/vless.mjs index eea7d9bc..135b42a2 100644 --- a/core/root/usr/share/xray/protocol/vless.mjs +++ b/core/root/usr/share/xray/protocol/vless.mjs @@ -41,7 +41,7 @@ export function vless_outbound(server, tag) { encryption: server["vless_encryption"] } ] - } + }; }) }, streamSettings: stream_settings_result diff --git a/status/Makefile b/status/Makefile index afa8afc4..a7ac5dd8 100644 --- a/status/Makefile +++ b/status/Makefile @@ -24,6 +24,7 @@ define Package/$(PKG_NAME)/description endef define Build/Compile + echo "luci-app-xray $(PKG_VERSION)-$(PKG_RELEASE) `git rev-parse HEAD` `date +%s`" > $(PKG_BUILD_DIR)/version.txt endef define Package/$(PKG_NAME)/install @@ -33,6 +34,8 @@ define Package/$(PKG_NAME)/install $(INSTALL_DATA) ./root/usr/share/luci/menu.d/luci-app-xray-status.json $(1)/usr/share/luci/menu.d/luci-app-xray-status.json $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d $(INSTALL_DATA) ./root/usr/share/rpcd/acl.d/luci-app-xray-status.json $(1)/usr/share/rpcd/acl.d/luci-app-xray-status.json + $(INSTALL_DIR) $(1)/usr/share/xray + $(INSTALL_DATA) $(PKG_BUILD_DIR)/version.txt $(1)/usr/share/xray/version.txt endef $(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/status/root/www/luci-static/resources/view/xray/status.js b/status/root/www/luci-static/resources/view/xray/status.js index ce1685fa..362c03a8 100644 --- a/status/root/www/luci-static/resources/view/xray/status.js +++ b/status/root/www/luci-static/resources/view/xray/status.js @@ -7,6 +7,13 @@ 'require view'; 'require view.xray.shared as shared'; +function bool_translate(v) { + if (v === "1") { + return _("available"); + } + return _("unavailable"); +} + function greater_than_zero(n) { if (n < 0) { return 0; @@ -297,17 +304,24 @@ function inbound_stats(vars, config) { return view.extend({ load: function () { - return uci.load(shared.variant); + return Promise.all([ + uci.load(shared.variant), + fs.read("/usr/share/xray/version.txt") + ]); }, - render: function (config) { - if (uci.get_first(config, "general", "metrics_server_enable") != "1") { + render: function (load_result) { + const config = load_result[0]; + if (uci.get_first(config, "general", "metrics_server_enable") !== "1") { return E([], [ E('h2', _('Xray (status)')), E('p', { 'class': 'cbi-map-descr' }, _("Xray metrics server not enabled. Enable Xray metrics server to see details.")) ]); } - const info = E('p', { 'class': 'cbi-map-descr' }, _("Collecting data. If any error occurs, check if wget is installed correctly.")); + const version = load_result[1].split(" "); + const stats_available = bool_translate(uci.get_first(config, "general", "stats")); + const observatory_available = bool_translate(uci.get_first(config, "general", "observatory")); + const info = E('p', { 'class': 'cbi-map-descr' }, `${version[0]} Version ${version[1]} (${version[2]}) Built ${new Date(version[3] * 1000).toLocaleString()}. Statistics: ${stats_available}. Observatory: ${observatory_available}.`); const detail = E('div', {}); poll.add(function () { fs.exec_direct("/usr/bin/wget", ["-O", "-", `http://127.0.0.1:${uci.get_first(config, "general", "metrics_server_port") || 18888}/debug/vars`], "json").then(function (vars) { @@ -319,7 +333,6 @@ return view.extend({ ]) ]); ui.tabs.initTabGroup(result.lastElementChild.childNodes); - dom.content(info, _("Show some statistics of Xray. If nothing here, enable statistics and / or observatory for Xray.")); dom.content(detail, result); }); });