From a05086ef86d05c1dd6f07dc15459d55557cf795f Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 16 Sep 2021 11:31:24 -0700 Subject: [PATCH] portlist: add debug knob to disable portlist collection For big servers. Per discussion with @crawshaw. Updates tailscale/corp#2566 Signed-off-by: Brad Fitzpatrick --- portlist/portlist.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/portlist/portlist.go b/portlist/portlist.go index 921f92066..977b51efe 100644 --- a/portlist/portlist.go +++ b/portlist/portlist.go @@ -6,7 +6,9 @@ package portlist import ( "fmt" + "os" "sort" + "strconv" "strings" ) @@ -72,7 +74,12 @@ func (pl List) String() string { return strings.TrimRight(sb.String(), "\n") } +var debugDisablePortlist, _ = strconv.ParseBool(os.Getenv("TS_DEBUG_DISABLE_PORTLIST")) + func GetList(prev List) (List, error) { + if debugDisablePortlist { + return nil, nil + } pl, err := listPorts() if err != nil { return nil, fmt.Errorf("listPorts: %s", err)