1
0
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:
v2ray
2016-02-25 21:50:10 +01:00
parent 59bc881d70
commit 76ca9de25f
10 changed files with 39 additions and 71 deletions

View File

@@ -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