Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
variables for background delays
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed May 8, 2018
1 parent 1562e1b commit 6d4bc41
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions autonat.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const (
NATStatusPrivate
)

var (
AutoNATBootDelay = 15 * time.Second
AutoNATRefreshInterval = 15 * time.Minute
)

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

0 comments on commit 6d4bc41

Please sign in to comment.