mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
feat(proxy): add sd_notify support
This commit is contained in:
parent
70974640ab
commit
fa5be44b69
4 changed files with 43 additions and 0 deletions
|
@ -822,6 +822,8 @@ func (sf *SnowflakeProxy) Start() error {
|
|||
}
|
||||
tokens = newTokens(sf.Capacity)
|
||||
|
||||
sdnotifyStatus("Checking NAT type...")
|
||||
|
||||
err = sf.checkNATType(config, sf.NATProbeURL)
|
||||
if err != nil {
|
||||
// non-fatal error. Log it and continue
|
||||
|
@ -830,6 +832,9 @@ func (sf *SnowflakeProxy) Start() error {
|
|||
}
|
||||
sf.EventDispatcher.OnNewSnowflakeEvent(event.EventOnCurrentNATTypeDetermined{CurNATType: getCurrentNATType()})
|
||||
|
||||
sdnotifyStatus(fmt.Sprintf("NAT type: %s", getCurrentNATType()))
|
||||
sdnotifyReady()
|
||||
|
||||
NatRetestTask := task.Periodic{
|
||||
Interval: sf.NATTypeMeasurementInterval,
|
||||
Execute: func() error {
|
||||
|
@ -846,6 +851,16 @@ func (sf *SnowflakeProxy) Start() error {
|
|||
defer NatRetestTask.Close()
|
||||
}
|
||||
|
||||
WatchdogTask := task.Periodic{
|
||||
Interval: 5 * time.Minute,
|
||||
Execute: func() error {
|
||||
sdnotifyWatchdog()
|
||||
return nil
|
||||
},
|
||||
}
|
||||
WatchdogTask.Start()
|
||||
defer WatchdogTask.Close()
|
||||
|
||||
ticker := time.NewTicker(sf.PollInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
|
@ -864,6 +879,7 @@ func (sf *SnowflakeProxy) Start() error {
|
|||
|
||||
// Stop closes all existing connections and shuts down the Snowflake.
|
||||
func (sf *SnowflakeProxy) Stop() {
|
||||
sdnotifyStopping()
|
||||
close(sf.shutdown)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue