diff --git a/env/env.go b/env/env.go index f7dfa84..69ed094 100644 --- a/env/env.go +++ b/env/env.go @@ -8,14 +8,8 @@ import ( ) var ( - TLS_VERIFY = os.Getenv("TLS_VERIFY") == "true" - DEBUG = os.Getenv("DEBUG") == "true" - OS_MAX_THREADS = func() int { - if value, err := strconv.Atoi(os.Getenv("OS_MAX_THREADS")); err == nil && value != 0 { - return value - } - return 10000 - }() + TLS_VERIFY = os.Getenv("TLS_VERIFY") == "true" + DEBUG = os.Getenv("DEBUG") == "true" ) // ExpandWithEnv updates string variables to their corresponding environment values. diff --git a/global/global.go b/global/global.go new file mode 100644 index 0000000..15ed4f2 --- /dev/null +++ b/global/global.go @@ -0,0 +1,21 @@ +package global + +import ( + "os" + "strconv" + + "github.com/projectdiscovery/utils/sysutil" +) + +var OS_MAX_THREADS int + +func init() { + OS_MAX_THREADS = func() int { + if value, err := strconv.Atoi(os.Getenv("OS_MAX_THREADS")); err == nil && value != 0 { + return value + } + return 10000 + }() + + _ = sysutil.SetMaxThreads(OS_MAX_THREADS) +}