diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-02-12 00:21:09 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-02-12 00:21:09 +0300 |
| commit | e5c0fe3edf3bc8ee44c13503cc39d4caba735ae9 (patch) | |
| tree | 87d72b513ebf0a34774b95e11d0598047c71fa95 /web/controller/inbound.go | |
| parent | f4057989f520daaef30b9d1cc0b0b0f12dbd7edc (diff) | |
bug fix #3785
Diffstat (limited to 'web/controller/inbound.go')
| -rw-r--r-- | web/controller/inbound.go | 32 |
1 files changed, 32 insertions, 0 deletions
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) } |
