Limit how often a busy tunnel can requery the lighthouse (#940)

Co-authored-by: Wade Simmons <wadey@slack-corp.com>
This commit is contained in:
Nate Brown
2023-08-08 13:26:41 -05:00
committed by GitHub
parent 5671c6607c
commit 223cc6e660
4 changed files with 62 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"math"
"os"
"os/signal"
"path/filepath"
@@ -236,6 +237,15 @@ func (c *C) GetInt(k string, d int) int {
return v
}
// GetUint32 will get the uint32 for k or return the default d if not found or invalid
func (c *C) GetUint32(k string, d uint32) uint32 {
r := c.GetInt(k, int(d))
if uint64(r) > uint64(math.MaxUint32) {
return d
}
return uint32(r)
}
// GetBool will get the bool for k or return the default d if not found or invalid
func (c *C) GetBool(k string, d bool) bool {
r := strings.ToLower(c.GetString(k, fmt.Sprintf("%v", d)))