github.com/moqsien/xraycore@v1.8.5/common/protocol/time.go (about) 1 package protocol 2 3 import ( 4 "time" 5 6 "github.com/moqsien/xraycore/common/dice" 7 ) 8 9 type Timestamp int64 10 11 type TimestampGenerator func() Timestamp 12 13 func NowTime() Timestamp { 14 return Timestamp(time.Now().Unix()) 15 } 16 17 func NewTimestampGenerator(base Timestamp, delta int) TimestampGenerator { 18 return func() Timestamp { 19 rangeInDelta := dice.Roll(delta*2) - delta 20 return base + Timestamp(rangeInDelta) 21 } 22 }