diff --git a/gui/src/locales/en.js b/gui/src/locales/en.js
index b49a4e68..0d9f9121 100644
--- a/gui/src/locales/en.js
+++ b/gui/src/locales/en.js
@@ -23,6 +23,7 @@ export default {
darkTheme: "Dark Theme",
lightTheme: "Light Theme",
autoTheme: "Auto Theme",
+ expand: "Show the connection status",
},
welcome: {
title: "Welcome",
diff --git a/gui/src/locales/fa-ir.js b/gui/src/locales/fa-ir.js
index 6c86f682..692d3473 100644
--- a/gui/src/locales/fa-ir.js
+++ b/gui/src/locales/fa-ir.js
@@ -23,6 +23,7 @@ export default {
darkTheme: "پوسته تاریک",
lightTheme: "پوسته روشن",
autoTheme: "پوسته خودکار",
+ expand: "نمایش وضعیت اتصال",
},
welcome: {
title: "خوش آمدید",
diff --git a/gui/src/locales/ko.js b/gui/src/locales/ko.js
index 1baf34a5..6246f2cb 100644
--- a/gui/src/locales/ko.js
+++ b/gui/src/locales/ko.js
@@ -23,6 +23,7 @@ export default {
darkTheme: "어두운 테마",
lightTheme: "밝은 테마",
autoTheme: "자동 테마",
+ expand: "연결 상태 표시",
},
welcome: {
title: "환영합니다",
diff --git a/gui/src/locales/pt-br.js b/gui/src/locales/pt-br.js
index f3e60d16..cdedb757 100644
--- a/gui/src/locales/pt-br.js
+++ b/gui/src/locales/pt-br.js
@@ -23,6 +23,7 @@ export default {
darkTheme: "Tema escuro",
lightTheme: "Tema claro",
autoTheme: "Tema automático",
+ expand: "Mostrar o estado da conexão",
},
welcome: {
title: "Boas-vindas",
diff --git a/gui/src/locales/ru.js b/gui/src/locales/ru.js
index 546ae4c7..42285be4 100644
--- a/gui/src/locales/ru.js
+++ b/gui/src/locales/ru.js
@@ -23,6 +23,7 @@ export default {
darkTheme: "Тёмная тема",
lightTheme: "Светлая тема",
autoTheme: "Автоматическая тема",
+ expand: "Показать состояние подключения",
},
welcome: {
title: "Добро пожаловать",
diff --git a/gui/src/locales/zh.js b/gui/src/locales/zh.js
index 52095455..3a7fef58 100644
--- a/gui/src/locales/zh.js
+++ b/gui/src/locales/zh.js
@@ -23,6 +23,7 @@ export default {
darkTheme: "深色主题",
lightTheme: "浅色主题",
autoTheme: "自动主题",
+ expand: "显示连接状态",
},
welcome: {
title: "欢迎使用",
diff --git a/gui/src/node.vue b/gui/src/node.vue
index 4f65d2ce..bca93fe7 100644
--- a/gui/src/node.vue
+++ b/gui/src/node.vue
@@ -8,7 +8,7 @@
@mouseenter.native="showSidebar = true"
@click.native="showSidebar = true"
>
-
+
.sidebar-content.is-fixed {
left: 1px;
top: 4.25rem;
diff --git a/service/server/service/subscription.go b/service/server/service/subscription.go
index c2e3007f..875e4290 100644
--- a/service/server/service/subscription.go
+++ b/service/server/service/subscription.go
@@ -105,21 +105,32 @@ type SubscriptionUserInfo struct {
Expire time.Time
}
+// Known reports whether the provider sent any usage field at all.
+func (sui *SubscriptionUserInfo) Known() bool {
+ return sui.Download != -1 || sui.Upload != -1 || sui.Total != -1 || !sui.Expire.IsZero()
+}
+
+// String renders the usage the way the node list shows it: what is used of
+// what is available, and the day it expires. It used to list every raw
+// field ("download: 0 GB; upload: 0 GB; total: 107 GB; expire: 2026-10-04
+// 18:59 UTC") in integer GB next to the provider's own text in GiB.
func (sui *SubscriptionUserInfo) String() string {
+ const gib = 1024 * 1024 * 1024
var outputs []string
- if sui.Download != -1 {
- outputs = append(outputs, fmt.Sprintf("download: %v GB", sui.Download/1e9))
- }
- if sui.Upload != -1 {
- outputs = append(outputs, fmt.Sprintf("upload: %v GB", sui.Upload/1e9))
- }
- if sui.Total != -1 {
- outputs = append(outputs, fmt.Sprintf("total: %v GB", sui.Total/1e9))
+ if sui.Download != -1 || sui.Upload != -1 {
+ used := float64(max(sui.Download, 0)+max(sui.Upload, 0)) / gib
+ if sui.Total > 0 {
+ outputs = append(outputs, fmt.Sprintf("Used %.2f GiB / %.2f GiB", used, float64(sui.Total)/gib))
+ } else {
+ outputs = append(outputs, fmt.Sprintf("Used %.2f GiB", used))
+ }
+ } else if sui.Total > 0 {
+ outputs = append(outputs, fmt.Sprintf("Total %.2f GiB", float64(sui.Total)/gib))
}
if !sui.Expire.IsZero() {
- outputs = append(outputs, fmt.Sprintf("expire: %v UTC", sui.Expire.Format("2006-01-02 15:04")))
+ outputs = append(outputs, "Expires "+sui.Expire.Local().Format("2006-01-02"))
}
- return strings.Join(outputs, "; ")
+ return strings.Join(outputs, " · ")
}
func parseSubscriptionUserInfo(str string) SubscriptionUserInfo {
@@ -201,11 +212,11 @@ func ResolveSubscriptionWithClient(source string, client *http.Client) (infos []
// node; treat an unparseable or empty body as a failed fetch
return nil, "", common.Coded("SUBSCRIPTION_EMPTY", fmt.Errorf("no server found in the subscription response"), nil)
}
- subscriptionUserInfo := res.Header.Get("Subscription-Userinfo")
- sui := parseSubscriptionUserInfo(subscriptionUserInfo)
- if len(status) > 0 {
- status = sui.String() + "|" + status
- } else {
+ // The Subscription-Userinfo header is the standard form of the usage; a
+ // STATUS= line in the body is the provider's own prose for the same
+ // numbers. Showing both printed every figure twice in two formats.
+ sui := parseSubscriptionUserInfo(res.Header.Get("Subscription-Userinfo"))
+ if sui.Known() {
status = sui.String()
}
return infos, status, nil
diff --git a/service/server/service/subscription_test.go b/service/server/service/subscription_test.go
new file mode 100644
index 00000000..fc34e456
--- /dev/null
+++ b/service/server/service/subscription_test.go
@@ -0,0 +1,46 @@
+package service
+
+import (
+ "testing"
+ "time"
+)
+
+func TestSubscriptionUserInfoString(t *testing.T) {
+ const gib = 1024 * 1024 * 1024
+ cases := []struct {
+ name string
+ sui SubscriptionUserInfo
+ want string
+ }{
+ {"usage and expiry", SubscriptionUserInfo{Upload: 0, Download: 1041529159, Total: 100 * gib, Expire: time.Date(2026, 10, 4, 18, 59, 0, 0, time.UTC)},
+ "Used 0.97 GiB / 100.00 GiB · Expires " + time.Date(2026, 10, 4, 18, 59, 0, 0, time.UTC).Local().Format("2006-01-02")},
+ {"no total", SubscriptionUserInfo{Upload: gib, Download: gib, Total: -1}, "Used 2.00 GiB"},
+ {"total only", SubscriptionUserInfo{Upload: -1, Download: -1, Total: 10 * gib}, "Total 10.00 GiB"},
+ {"nothing", SubscriptionUserInfo{Upload: -1, Download: -1, Total: -1}, ""},
+ }
+ for _, c := range cases {
+ if got := c.sui.String(); got != c.want {
+ t.Errorf("%s: got %q, want %q", c.name, got, c.want)
+ }
+ if c.sui.Known() != (c.want != "") {
+ t.Errorf("%s: Known() disagrees with the rendered text", c.name)
+ }
+ }
+}
+
+func TestParseSubscriptionUserInfoHeader(t *testing.T) {
+ sui := parseSubscriptionUserInfo("upload=0; download=1041529159; total=107374182400; expire=1791140340")
+ if sui.Upload != 0 || sui.Download != 1041529159 || sui.Total != 107374182400 {
+ t.Fatalf("fields: %+v", sui)
+ }
+ if sui.Expire.UTC().Format("2006-01-02 15:04") != "2026-10-04 18:59" {
+ t.Fatalf("expire: %v", sui.Expire)
+ }
+ if !sui.Known() {
+ t.Fatal("a header with fields must count as known")
+ }
+ empty := parseSubscriptionUserInfo("")
+ if empty.Known() {
+ t.Fatal("an empty header must not count as known")
+ }
+}