mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-04 16:37:12 -05:00
Remove call to UTC() which is not necessary.
This commit is contained in:
parent
d0ae47e2ce
commit
fdb41bbd50
@ -72,7 +72,7 @@ func (queue *TimedQueue) RemovedEntries() <-chan interface{} {
|
|||||||
|
|
||||||
func (queue *TimedQueue) cleanup(tick <-chan time.Time) {
|
func (queue *TimedQueue) cleanup(tick <-chan time.Time) {
|
||||||
for now := range tick {
|
for now := range tick {
|
||||||
nowSec := now.UTC().Unix()
|
nowSec := now.Unix()
|
||||||
for {
|
for {
|
||||||
queue.access.RLock()
|
queue.access.RLock()
|
||||||
queueLen := queue.queue.Len()
|
queueLen := queue.queue.Len()
|
||||||
|
@ -12,7 +12,7 @@ func TestTimedQueue(t *testing.T) {
|
|||||||
|
|
||||||
removed := make(map[string]bool)
|
removed := make(map[string]bool)
|
||||||
|
|
||||||
nowSec := time.Now().UTC().Unix()
|
nowSec := time.Now().Unix()
|
||||||
q := NewTimedQueue(2)
|
q := NewTimedQueue(2)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@ -51,7 +51,7 @@ func TestTimedQueue(t *testing.T) {
|
|||||||
<-tick
|
<-tick
|
||||||
assert.Bool(removed["Values"]).IsFalse()
|
assert.Bool(removed["Values"]).IsFalse()
|
||||||
|
|
||||||
q.Add("Value1", time.Now().UTC().Unix()+10)
|
q.Add("Value1", time.Now().Unix()+10)
|
||||||
|
|
||||||
<-tick
|
<-tick
|
||||||
v1, ok = removed["Value1"]
|
v1, ok = removed["Value1"]
|
||||||
|
@ -63,10 +63,10 @@ func (us *TimedUserSet) generateNewHashes(lastSec, nowSec int64, idx int, id *co
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (us *TimedUserSet) updateUserHash(tick <-chan time.Time) {
|
func (us *TimedUserSet) updateUserHash(tick <-chan time.Time) {
|
||||||
lastSec := time.Now().UTC().Unix() - cacheDurationSec
|
lastSec := time.Now().Unix() - cacheDurationSec
|
||||||
|
|
||||||
for now := range tick {
|
for now := range tick {
|
||||||
nowSec := now.UTC().Unix() + cacheDurationSec
|
nowSec := now.Unix() + cacheDurationSec
|
||||||
for idx, id := range us.validUserIds {
|
for idx, id := range us.validUserIds {
|
||||||
us.generateNewHashes(lastSec, nowSec, idx, id)
|
us.generateNewHashes(lastSec, nowSec, idx, id)
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ func (us *TimedUserSet) AddUser(user config.User) error {
|
|||||||
idx := len(us.validUserIds)
|
idx := len(us.validUserIds)
|
||||||
us.validUserIds = append(us.validUserIds, id)
|
us.validUserIds = append(us.validUserIds, id)
|
||||||
|
|
||||||
nowSec := time.Now().UTC().Unix()
|
nowSec := time.Now().Unix()
|
||||||
lastSec := nowSec - cacheDurationSec
|
lastSec := nowSec - cacheDurationSec
|
||||||
us.generateNewHashes(lastSec, nowSec+cacheDurationSec, idx, id)
|
us.generateNewHashes(lastSec, nowSec+cacheDurationSec, idx, id)
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ func (request *VMessRequest) ToBytes(idHash user.CounterHash, randomRangeInt64 u
|
|||||||
buffer = alloc.NewSmallBuffer().Clear()
|
buffer = alloc.NewSmallBuffer().Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
counter := randomRangeInt64(time.Now().UTC().Unix(), 30)
|
counter := randomRangeInt64(time.Now().Unix(), 30)
|
||||||
hash := idHash.Hash(request.UserId.Bytes[:], counter)
|
hash := idHash.Hash(request.UserId.Bytes[:], counter)
|
||||||
|
|
||||||
buffer.Append(hash)
|
buffer.Append(hash)
|
||||||
|
Loading…
Reference in New Issue
Block a user