mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-28 04:55:37 -05:00
refactor protocol
This commit is contained in:
@@ -2,6 +2,7 @@ package protocol
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
)
|
||||
@@ -14,6 +15,10 @@ func (this Timestamp) Bytes() []byte {
|
||||
|
||||
type TimestampGenerator func() Timestamp
|
||||
|
||||
func NowTime() Timestamp {
|
||||
return Timestamp(time.Now().Unix())
|
||||
}
|
||||
|
||||
func NewTimestampGenerator(base Timestamp, delta int) TimestampGenerator {
|
||||
return func() Timestamp {
|
||||
rangeInDelta := rand.Intn(delta*2) - delta
|
||||
|
||||
Reference in New Issue
Block a user