Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2026-02-12 00:21:09 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2026-02-12 00:21:09 +0300
commite5c0fe3edf3bc8ee44c13503cc39d4caba735ae9 (patch)
tree87d72b513ebf0a34774b95e11d0598047c71fa95 /web/service
parentf4057989f520daaef30b9d1cc0b0b0f12dbd7edc (diff)
bug fix #3785
Diffstat (limited to 'web/service')
-rw-r--r--web/service/inbound.go37
-rw-r--r--web/service/tgbot.go35
2 files changed, 71 insertions, 1 deletions
diff --git a/web/service/inbound.go b/web/service/inbound.go
index 469fa561..ec51bc27 100644
--- a/web/service/inbound.go
+++ b/web/service/inbound.go
@@ -2141,6 +2141,43 @@ func (s *InboundService) GetInboundClientIps(clientEmail string) (string, error)
if err != nil {
return "", err
}
+
+ if InboundClientIps.Ips == "" {
+ return "", nil
+ }
+
+ // Try to parse as new format (with timestamps)
+ type IPWithTimestamp struct {
+ IP string `json:"ip"`
+ Timestamp int64 `json:"timestamp"`
+ }
+
+ var ipsWithTime []IPWithTimestamp
+ err = json.Unmarshal([]byte(InboundClientIps.Ips), &ipsWithTime)
+
+ // If successfully parsed as new format, return with timestamps
+ if err == nil && len(ipsWithTime) > 0 {
+ return InboundClientIps.Ips, nil
+ }
+
+ // Otherwise, assume it's old format (simple string array)
+ // Try to parse as simple array and convert to new format
+ var oldIps []string
+ err = json.Unmarshal([]byte(InboundClientIps.Ips), &oldIps)
+ if err == nil && len(oldIps) > 0 {
+ // Convert old format to new format with current timestamp
+ newIpsWithTime := make([]IPWithTimestamp, len(oldIps))
+ for i, ip := range oldIps {
+ newIpsWithTime[i] = IPWithTimestamp{
+ IP: ip,
+ Timestamp: time.Now().Unix(),
+ }
+ }
+ result, _ := json.Marshal(newIpsWithTime)
+ return string(result), nil
+ }
+
+ // Return as-is if parsing fails
return InboundClientIps.Ips, nil
}
diff --git a/web/service/tgbot.go b/web/service/tgbot.go
index cb84142c..52df9092 100644
--- a/web/service/tgbot.go
+++ b/web/service/tgbot.go
@@ -5,6 +5,7 @@ import (
"crypto/rand"
"embed"
"encoding/base64"
+ "encoding/json"
"errors"
"fmt"
"io"
@@ -3083,9 +3084,41 @@ func (t *Tgbot) searchClientIps(chatId int64, email string, messageID ...int) {
ips = t.I18nBot("tgbot.noIpRecord")
}
+ formattedIps := ips
+ if err == nil && len(ips) > 0 {
+ type ipWithTimestamp struct {
+ IP string `json:"ip"`
+ Timestamp int64 `json:"timestamp"`
+ }
+
+ var ipsWithTime []ipWithTimestamp
+ if json.Unmarshal([]byte(ips), &ipsWithTime) == nil && len(ipsWithTime) > 0 {
+ lines := make([]string, 0, len(ipsWithTime))
+ for _, item := range ipsWithTime {
+ if item.IP == "" {
+ continue
+ }
+ if item.Timestamp > 0 {
+ ts := time.Unix(item.Timestamp, 0).Format("2006-01-02 15:04:05")
+ lines = append(lines, fmt.Sprintf("%s (%s)", item.IP, ts))
+ continue
+ }
+ lines = append(lines, item.IP)
+ }
+ if len(lines) > 0 {
+ formattedIps = strings.Join(lines, "\n")
+ }
+ } else {
+ var oldIps []string
+ if json.Unmarshal([]byte(ips), &oldIps) == nil && len(oldIps) > 0 {
+ formattedIps = strings.Join(oldIps, "\n")
+ }
+ }
+ }
+
output := ""
output += t.I18nBot("tgbot.messages.email", "Email=="+email)
- output += t.I18nBot("tgbot.messages.ips", "IPs=="+ips)
+ output += t.I18nBot("tgbot.messages.ips", "IPs=="+formattedIps)
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
inlineKeyboard := tu.InlineKeyboard(