diff --git a/web/assets/js/util/common.js b/web/assets/js/util/common.js
index 6dad047d..ab642849 100644
--- a/web/assets/js/util/common.js
+++ b/web/assets/js/util/common.js
@@ -5,7 +5,9 @@ const ONE_TB = ONE_GB * 1024;
const ONE_PB = ONE_TB * 1024;
function sizeFormat(size) {
- if (size < ONE_KB) {
+ if (size < 0) {
+ return "0 B";
+ } else if (size < ONE_KB) {
return size.toFixed(0) + " B";
} else if (size < ONE_MB) {
return (size / ONE_KB).toFixed(2) + " KB";
diff --git a/web/html/xui/index.html b/web/html/xui/index.html
index 667cd4cb..7d919a30 100644
--- a/web/html/xui/index.html
+++ b/web/html/xui/index.html
@@ -34,7 +34,8 @@
:stroke-color="status.cpu.color"
:class="themeSwitcher.darkCardClass"
:percent="status.cpu.percent">
-
CPU
+ Cores: [[ status.cpuCores ]]
+ Logical Procs: [[ status.logicalProcessors ]]
- {{ i18n "pages.index.operationHours" }}:
- [[ formatSecond(status.uptime) ]]
-
-
- {{ i18n "pages.index.operationHoursDesc" }}
-
-
-
+ {{ i18n "menu.link" }}:
+ {{ i18n "pages.index.logs" }}
+ {{ i18n "pages.index.config" }}
+ {{ i18n "pages.index.backup" }}
@@ -111,26 +108,69 @@
- {{ i18n "menu.link" }}:
- {{ i18n "pages.index.logs" }}
- {{ i18n "pages.index.config" }}
- {{ i18n "pages.index.backup" }}
+
+
+ {{ i18n "pages.index.systemLoad" }}: [[ status.loads[0] ]] | [[ status.loads[1] ]] | [[ status.loads[2] ]]
+
+
+ {{ i18n "pages.index.systemLoadDesc" }}
+
+
+
+
+
+ {{ i18n "pages.index.operationHours" }}:
+ [[ formatSecond(status.uptime) ]]
+
+
- {{ i18n "pages.index.systemLoad" }}: [[ status.loads[0] ]] | [[ status.loads[1] ]] | [[ status.loads[2] ]]
+
+
+ ipv4:
+
+
+ [[ status.publicIP.ipv4 ]]
+
+
+
+
+
+ ipv6:
+
+
+ [[ status.publicIP.ipv6 ]]
+
+
+
+
+
-
+
- TCP / UDP {{ i18n "pages.index.connectionCount" }}: [[ status.tcpCount ]] / [[ status.udpCount ]]
-
-
- {{ i18n "pages.index.connectionCountDesc" }}
-
-
-
+
+
+ TCP: [[ status.tcpCount ]]
+
+
+ {{ i18n "pages.index.connectionTcpCountDesc" }}
+
+
+
+
+
+ UDP: [[ status.udpCount ]]
+
+
+ {{ i18n "pages.index.connectionUdpCountDesc" }}
+
+
+
+
+
@@ -299,9 +339,12 @@
this.mem = new CurTotal(0, 0);
this.netIO = { up: 0, down: 0 };
this.netTraffic = { sent: 0, recv: 0 };
+ this.publicIP = { ipv4: 0, ipv6: 0 };
this.swap = new CurTotal(0, 0);
this.tcpCount = 0;
this.udpCount = 0;
+ this.cpuCores = 0;
+ this.logicalProcessors = 0;
this.uptime = 0;
this.xray = { state: State.Stop, errorMsg: "", version: "", color: "" };
@@ -314,9 +357,12 @@
this.mem = new CurTotal(data.mem.current, data.mem.total);
this.netIO = data.netIO;
this.netTraffic = data.netTraffic;
+ this.publicIP = data.publicIP;
this.swap = new CurTotal(data.swap.current, data.swap.total);
this.tcpCount = data.tcpCount;
this.udpCount = data.udpCount;
+ this.cpuCores = data.cpuCores;
+ this.logicalProcessors = data.logicalProcessors;
this.uptime = data.uptime;
this.xray = data.xray;
switch (this.xray.state) {
diff --git a/web/service/server.go b/web/service/server.go
index d0ca6e21..cace8eba 100644
--- a/web/service/server.go
+++ b/web/service/server.go
@@ -38,9 +38,11 @@ const (
)
type Status struct {
- T time.Time `json:"-"`
- Cpu float64 `json:"cpu"`
- Mem struct {
+ T time.Time `json:"-"`
+ Cpu float64 `json:"cpu"`
+ CpuCores int `json:"cpuCores"`
+ LogicalProcessors int `json:"logicalProcessors"`
+ Mem struct {
Current uint64 `json:"current"`
Total uint64 `json:"total"`
} `json:"mem"`
@@ -69,6 +71,10 @@ type Status struct {
Sent uint64 `json:"sent"`
Recv uint64 `json:"recv"`
} `json:"netTraffic"`
+ PublicIP struct {
+ IPv4 string `json:"ipv4"`
+ IPv6 string `json:"ipv6"`
+ } `json:"publicIP"`
}
type Release struct {
@@ -80,6 +86,33 @@ type ServerService struct {
inboundService InboundService
}
+const DebugMode = false // Set to true during development
+
+func getPublicIP(url string) string {
+ resp, err := http.Get(url)
+ if err != nil {
+ if DebugMode {
+ logger.Warning("get public IP failed:", err)
+ }
+ return "N/A"
+ }
+ defer resp.Body.Close()
+
+ ip, err := io.ReadAll(resp.Body)
+ if err != nil {
+ if DebugMode {
+ logger.Warning("read public IP failed:", err)
+ }
+ return "N/A"
+ }
+
+ if string(ip) == "" {
+ return "N/A" // default value
+ }
+
+ return string(ip)
+}
+
func (s *ServerService) GetStatus(lastStatus *Status) *Status {
now := time.Now()
status := &Status{
@@ -93,6 +126,13 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
status.Cpu = percents[0]
}
+ status.CpuCores, err = cpu.Counts(false)
+ if err != nil {
+ logger.Warning("get cpu cores count failed:", err)
+ }
+
+ status.LogicalProcessors = runtime.NumCPU()
+
upTime, err := host.Uptime()
if err != nil {
logger.Warning("get uptime failed:", err)
@@ -161,6 +201,9 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
logger.Warning("get udp connections failed:", err)
}
+ status.PublicIP.IPv4 = getPublicIP("https://api.ipify.org")
+ status.PublicIP.IPv6 = getPublicIP("https://api6.ipify.org")
+
if s.xrayService.IsXrayRunning() {
status.Xray.State = Running
status.Xray.ErrorMsg = ""
diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml
index 3b2303ac..25872f98 100644
--- a/web/translation/translate.en_US.toml
+++ b/web/translation/translate.en_US.toml
@@ -75,14 +75,15 @@
"xrayStatus" = "Xray Status"
"stopXray" = "Stop"
"restartXray" = "Restart"
-"xraySwitch" = "Switch Version"
+"xraySwitch" = "SwitchV"
"xraySwitchClick" = "Choose the version you want to switch to."
"xraySwitchClickDesk" = "Choose wisely, as older versions may not be compatible with current configurations."
-"operationHours" = "Operation Hours"
-"operationHoursDesc" = "System uptime: time since startup."
+"operationHours" = "Uptime"
"systemLoad" = "System Load"
+"systemLoadDesc" = "system load average for the past 1, 5, and 15 minutes"
+"connectionTcpCountDesc" = "Total TCP connections across all network cards."
+"connectionUdpCountDesc" = "Total UDP connections across all network cards."
"connectionCount" = "Number of Connections"
-"connectionCountDesc" = "Total connections across all network cards."
"upSpeed" = "Total upload speed for all network cards."
"downSpeed" = "Total download speed for all network cards."
"totalSent" = "Total upload traffic of all network cards since system startup."
diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml
index 2dd2988b..93419352 100644
--- a/web/translation/translate.fa_IR.toml
+++ b/web/translation/translate.fa_IR.toml
@@ -78,11 +78,12 @@
"xraySwitch" = "تغییر ورژن"
"xraySwitchClick" = "ورژن مورد نظر را انتخاب کنید"
"xraySwitchClickDesk" = "لطفا با دقت انتخاب کنید ، در صورت انتخاب اشتباه امکان قطعی سیستم وجود دارد "
-"operationHours" = "مدت فعالیت"
-"operationHoursDesc" = "مدت فعالیت سیستم بعد از روشن شدن"
-"systemLoad" = "بار روی سیستم"
+"operationHours" = "آپ تایم سیستم"
+"systemLoad" = "بار سیستم"
+"systemLoadDesc" = "میانگین بار سیستم برای 1، 5 و 15 دقیقه گذشته"
+"connectionTcpCountDesc" = "مجموع اتصالات TCP در تمام کارت های شبکه"
+"connectionUdpCountDesc" = "مجموع اتصالات UDP در تمام کارت های شبکه"
"connectionCount" = "تعداد کانکشن ها"
-"connectionCountDesc" = "تعداد کانکشن ها برای کل شبکه"
"upSpeed" = "سرعت آپلود در حال حاضر سیستم"
"downSpeed" = "سرعت دانلود در حال حاضر سیستم"
"totalSent" = "جمع کل ترافیک آپلود مصرفی"
diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml
index e746172c..a25f0e6a 100644
--- a/web/translation/translate.ru_RU.toml
+++ b/web/translation/translate.ru_RU.toml
@@ -78,11 +78,12 @@
"xraySwitch" = "Переключить версию"
"xraySwitchClick" = "Выберите желаемую версию"
"xraySwitchClickDesk" = "Выбирайте внимательно, так как старые версии могут быть несовместимы с текущими конфигурациями"
-"operationHours" = "Часы работы"
-"operationHoursDesc" = "Аптайм системы: время системы в сети"
+"operationHours" = "Время работы системы"
"systemLoad" = "Системная нагрузка"
+"systemLoadDesc" = "средняя загрузка системы за последние 1, 5 и 15 минут"
+"connectionTcpCountDesc" = "Всего подключений TCP по всем сетевым картам."
+"connectionUdpCountDesc" = "Общее количество подключений UDP по всем сетевым картам."
"connectionCount" = "Количество соединений"
-"connectionCountDesc" = "Всего подключений по всем сетям"
"upSpeed" = "Общая скорость upload для всех сетей"
"downSpeed" = "Общая скорость download для всех сетей"
"totalSent" = "Общий объем загруженных данных для всех сетей с момента запуска системы"
diff --git a/web/translation/translate.zh_Hans.toml b/web/translation/translate.zh_Hans.toml
index 79234c98..c77549b1 100644
--- a/web/translation/translate.zh_Hans.toml
+++ b/web/translation/translate.zh_Hans.toml
@@ -78,11 +78,12 @@
"xraySwitch" = "切换版本"
"xraySwitchClick" = "点击你想切换的版本"
"xraySwitchClickDesk" = "请谨慎选择,旧版本可能配置不兼容"
-"operationHours" = "运行时间"
-"operationHoursDesc" = "系统自启动以来的运行时间"
+"operationHours" = "系统正常运行时间"
"systemLoad" = "系统负载"
+"systemLoadDesc" = "过去 1、5 和 15 分钟的系统平均负载"
+"connectionTcpCountDesc" = "所有网卡的总 TCP 连接数。"
+"connectionUdpCountDesc" = "所有网卡的总 UDP 连接数。"
"connectionCount" = "连接数"
-"connectionCountDesc" = "所有网卡的总连接数"
"upSpeed" = "所有网卡的总上传速度"
"downSpeed" = "所有网卡的总下载速度"
"totalSent" = "系统启动以来所有网卡的总上传流量"