variables for background delays

This commit is contained in:
vyzo 2018-05-08 16:17:05 +03:00
parent 2584bc51ff
commit 003e697e6a
1 changed files with 7 additions and 2 deletions

View File

@ -20,6 +20,11 @@ const (
NATStatusPrivate NATStatusPrivate
) )
var (
AutoNATBootDelay = 15 * time.Second
AutoNATRefreshInterval = 15 * time.Minute
)
type AutoNAT interface { type AutoNAT interface {
Status() NATStatus Status() NATStatus
PublicAddr() (ma.Multiaddr, error) PublicAddr() (ma.Multiaddr, error)
@ -66,11 +71,11 @@ func (as *AmbientAutoNAT) PublicAddr() (ma.Multiaddr, error) {
func (as *AmbientAutoNAT) background() { func (as *AmbientAutoNAT) background() {
// wait a bit for the node to come online and establish some connections // wait a bit for the node to come online and establish some connections
// before starting autodetection // before starting autodetection
time.Sleep(15 * time.Second) time.Sleep(AutoNATBootDelay)
for { for {
as.autodetect() as.autodetect()
select { select {
case <-time.After(15 * time.Minute): case <-time.After(AutoNATRefreshInterval):
case <-as.ctx.Done(): case <-as.ctx.Done():
return return
} }