mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
https://github.com/XTLS/Xray-core/issues/4996#issuecomment-3855274627 https://github.com/XTLS/Xray-core/pull/5658#issuecomment-3857332687 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> Co-authored-by: Fangliding <63339210+Fangliding@users.noreply.github.com>
29 lines
878 B
Go
29 lines
878 B
Go
package utils
|
|
|
|
import (
|
|
"math/rand"
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/klauspost/cpuid/v2"
|
|
)
|
|
|
|
func ChromeVersion() int {
|
|
// Use only CPU info as seed for PRNG
|
|
seed := int64(cpuid.CPU.Family + cpuid.CPU.Model + cpuid.CPU.PhysicalCores + cpuid.CPU.LogicalCores + cpuid.CPU.CacheLine)
|
|
rng := rand.New(rand.NewSource(seed))
|
|
// Start from Chrome 144 released on 2026.1.13
|
|
releaseDate := time.Date(2026, 1, 13, 0, 0, 0, 0, time.UTC)
|
|
version := 144
|
|
now := time.Now()
|
|
// Each version has random 25-45 day interval
|
|
for releaseDate.Before(now) {
|
|
releaseDate = releaseDate.AddDate(0, 0, rng.Intn(21)+25)
|
|
version++
|
|
}
|
|
return version - 1
|
|
}
|
|
|
|
// ChromeUA provides default browser User-Agent based on CPU-seeded PRNG.
|
|
var ChromeUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/" + strconv.Itoa(ChromeVersion()) + ".0.0.0 Safari/537.36"
|