Maint: openvpn package split files
This commit is contained in:
36
internal/openvpn/helpers.go
Normal file
36
internal/openvpn/helpers.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package openvpn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
func (l *looper) signalOrSetStatus(status models.LoopStatus) {
|
||||
if l.userTrigger {
|
||||
l.userTrigger = false
|
||||
select {
|
||||
case l.running <- status:
|
||||
default: // receiver calling ApplyStatus dropped out
|
||||
}
|
||||
} else {
|
||||
l.statusManager.SetStatus(status)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *looper) logAndWait(ctx context.Context, err error) {
|
||||
if err != nil {
|
||||
l.logger.Error(err.Error())
|
||||
}
|
||||
l.logger.Info("retrying in " + l.backoffTime.String())
|
||||
timer := time.NewTimer(l.backoffTime)
|
||||
l.backoffTime *= 2
|
||||
select {
|
||||
case <-timer.C:
|
||||
case <-ctx.Done():
|
||||
if !timer.Stop() {
|
||||
<-timer.C
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user