mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
use const LogTimeInterval
This commit is contained in:
parent
5aae41c901
commit
8a8273e972
1 changed files with 7 additions and 3 deletions
|
@ -5,6 +5,10 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
LogTimeInterval = 5
|
||||
)
|
||||
|
||||
type BytesInfo struct {
|
||||
outboundChan chan int
|
||||
inboundChan chan int
|
||||
|
@ -33,18 +37,18 @@ func (b *BytesInfo) Log() {
|
|||
b.outbound += amount
|
||||
b.outEvents++
|
||||
last := time.Now()
|
||||
if time.Since(last) > time.Second*5 {
|
||||
if time.Since(last) > time.Second*LogTimeInterval {
|
||||
last = time.Now()
|
||||
output()
|
||||
}
|
||||
case amount = <-b.inboundChan:
|
||||
b.inbound += amount
|
||||
b.inEvents++
|
||||
if time.Since(last) > time.Second*5 {
|
||||
if time.Since(last) > time.Second*LogTimeInterval {
|
||||
last = time.Now()
|
||||
output()
|
||||
}
|
||||
case <-time.After(time.Second * 5):
|
||||
case <-time.After(time.Second * LogTimeInterval):
|
||||
if b.inEvents > 0 || b.outEvents > 0 {
|
||||
output()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue