Fix: Incorrect time in xray logs (#3587)

* fixed timezone in xray logs

* remove leading / at the address
This commit is contained in:
fgsfds 2025-11-09 04:42:02 +05:00 committed by GitHub
parent cf38226b5d
commit 538f7fd5d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -844,9 +844,11 @@
text = `<td>${log.Email}</td>`; text = `<td>${log.Email}</td>`;
} }
const { locale, timeZone } = Intl.DateTimeFormat().resolvedOptions();
formattedLogs += ` formattedLogs += `
<tr ${outboundColor}> <tr ${outboundColor}>
<td><b>${new Date(log.DateTime).toLocaleString()}</b></td> <td><b>${new Date(log.DateTime).toLocaleString(locale, { timeZone })}</b></td>
<td>${log.FromAddress}</td> <td>${log.FromAddress}</td>
<td>${log.ToAddress}</td> <td>${log.ToAddress}</td>
<td>${log.Inbound}</td> <td>${log.Inbound}</td>

View file

@ -794,17 +794,17 @@ func (s *ServerService) GetXrayLogs(
for i, part := range parts { for i, part := range parts {
if i == 0 { if i == 0 {
dateTime, err := time.Parse("2006/01/02 15:04:05.999999", parts[0]+" "+parts[1]) dateTime, err := time.ParseInLocation("2006/01/02 15:04:05.999999", parts[0]+" "+parts[1], time.Local)
if err != nil { if err != nil {
continue continue
} }
entry.DateTime = dateTime entry.DateTime = dateTime.UTC()
} }
if part == "from" { if part == "from" {
entry.FromAddress = parts[i+1] entry.FromAddress = strings.TrimLeft(parts[i+1], "/")
} else if part == "accepted" { } else if part == "accepted" {
entry.ToAddress = parts[i+1] entry.ToAddress = strings.TrimLeft(parts[i+1], "/")
} else if strings.HasPrefix(part, "[") { } else if strings.HasPrefix(part, "[") {
entry.Inbound = part[1:] entry.Inbound = part[1:]
} else if strings.HasSuffix(part, "]") { } else if strings.HasSuffix(part, "]") {