From b1d2e8982aa0d4cd22a48bc36dad9782b5a364bf Mon Sep 17 00:00:00 2001 From: viettranx Date: Wed, 4 Mar 2026 23:25:34 +0700 Subject: [PATCH] fix: nil guard for QueryTodaySummary, correct remoteAddr comment and UI Co-Authored-By: Claude Opus 4.6 --- internal/channels/quota.go | 3 +++ internal/gateway/client.go | 2 +- ui/web/src/pages/overview/overview-page.tsx | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/channels/quota.go b/internal/channels/quota.go index e07ca209..02720307 100644 --- a/internal/channels/quota.go +++ b/internal/channels/quota.go @@ -265,6 +265,9 @@ func (qc *QuotaChecker) Usage(ctx context.Context) QuotaUsageResult { // QueryTodaySummary fills today's aggregate stats into the result. // Exported so QuotaMethods can call it directly when QuotaChecker is nil. func QueryTodaySummary(ctx context.Context, db *sql.DB, result *QuotaUsageResult) { + if db == nil { + return + } now := time.Now().UTC() startOfDay := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC) diff --git a/internal/gateway/client.go b/internal/gateway/client.go index 45bfcc6d..420a0d87 100644 --- a/internal/gateway/client.go +++ b/internal/gateway/client.go @@ -26,7 +26,7 @@ type Client struct { mu sync.Mutex connectedAt time.Time // when the client connected - remoteAddr string // peer IP:port from websocket + remoteAddr string // peer IP (extracted from proxy headers or RemoteAddr) // Browser pairing state pairingCode string // 8-char code if pending approval diff --git a/ui/web/src/pages/overview/overview-page.tsx b/ui/web/src/pages/overview/overview-page.tsx index c8fa41a6..862cd153 100644 --- a/ui/web/src/pages/overview/overview-page.tsx +++ b/ui/web/src/pages/overview/overview-page.tsx @@ -621,7 +621,7 @@ export function OverviewPage() { className={`border-b last:border-0 ${isYou ? "bg-muted/50" : ""}`} > - {c.remoteAddr.replace(/:\d+$/, "")} + {c.remoteAddr} {isYou && (