github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/common/protocol/time.go (about) 1 package protocol 2 3 import ( 4 "time" 5 6 "v2ray.com/core/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 }