mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Move creation of periodic stats task inside proxy library
This adds a new type of SnowflakeEvent. EventOnProxyStats is triggered by the periodic task run at SummaryInterval and produces an event with a proxy stats output string.
This commit is contained in:
parent
83a7422fe6
commit
354cb65432
4 changed files with 54 additions and 19 deletions
|
@ -139,6 +139,14 @@ type SnowflakeProxy struct {
|
|||
ProxyType string
|
||||
EventDispatcher event.SnowflakeEventDispatcher
|
||||
shutdown chan struct{}
|
||||
|
||||
// DisableStatsLogger indicates whether proxy stats will be logged periodically
|
||||
DisableStatsLogger bool
|
||||
// SummaryInterval is the time interval at which proxy stats will be logged
|
||||
SummaryInterval time.Duration
|
||||
|
||||
periodicProxyStats *periodicProxyStats
|
||||
bytesLogger bytesLogger
|
||||
}
|
||||
|
||||
// Checks whether an IP address is a remote address for the client
|
||||
|
@ -654,6 +662,10 @@ func (sf *SnowflakeProxy) Start() error {
|
|||
sf.EventDispatcher = event.NewSnowflakeEventDispatcher()
|
||||
}
|
||||
|
||||
if !sf.DisableStatsLogger {
|
||||
sf.periodicProxyStats = newPeriodicProxyStats(sf.SummaryInterval, sf.EventDispatcher)
|
||||
}
|
||||
|
||||
broker, err = newSignalingServer(sf.BrokerURL, sf.KeepLocalAddresses)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error configuring broker: %s", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue