From e5c0fe3edf3bc8ee44c13503cc39d4caba735ae9 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Wed, 11 Feb 2026 22:21:09 +0100 Subject: bug fix #3785 --- web/controller/inbound.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'web/controller/inbound.go') diff --git a/web/controller/inbound.go b/web/controller/inbound.go index 8317de31..b012ec95 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "strconv" + "time" "github.com/mhsanaei/3x-ui/v2/database/model" "github.com/mhsanaei/3x-ui/v2/web/service" @@ -193,6 +194,37 @@ func (a *InboundController) getClientIps(c *gin.Context) { return } + // Prefer returning a normalized string list for consistent UI rendering + type ipWithTimestamp struct { + IP string `json:"ip"` + Timestamp int64 `json:"timestamp"` + } + + var ipsWithTime []ipWithTimestamp + if err := json.Unmarshal([]byte(ips), &ipsWithTime); err == nil && len(ipsWithTime) > 0 { + formatted := make([]string, 0, len(ipsWithTime)) + for _, item := range ipsWithTime { + if item.IP == "" { + continue + } + if item.Timestamp > 0 { + ts := time.Unix(item.Timestamp, 0).Local().Format("2006-01-02 15:04:05") + formatted = append(formatted, fmt.Sprintf("%s (%s)", item.IP, ts)) + continue + } + formatted = append(formatted, item.IP) + } + jsonObj(c, formatted, nil) + return + } + + var oldIps []string + if err := json.Unmarshal([]byte(ips), &oldIps); err == nil && len(oldIps) > 0 { + jsonObj(c, oldIps, nil) + return + } + + // If parsing fails, return as string jsonObj(c, ips, nil) } -- cgit v1.2.3