mirror of
https://github.com/everywall/ladder.git
synced 2024-10-03 23:29:04 +03:00
overriding default timeout via HTTP_TIMEOUT env variable.
This commit is contained in:
parent
a849603d8b
commit
92b5233257
@ -8,6 +8,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -22,6 +23,7 @@ var (
|
||||
ForwardedFor = getenv("X_FORWARDED_FOR", "66.249.66.1")
|
||||
rulesSet = ruleset.NewRulesetFromEnv()
|
||||
allowedDomains = []string{}
|
||||
defaultTimeout = 15 // in seconds
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -29,6 +31,9 @@ func init() {
|
||||
if os.Getenv("ALLOWED_DOMAINS_RULESET") == "true" {
|
||||
allowedDomains = append(allowedDomains, rulesSet.Domains()...)
|
||||
}
|
||||
if timeoutStr := os.Getenv("HTTP_TIMEOUT"); timeoutStr != "" {
|
||||
defaultTimeout, _ = strconv.Atoi(timeoutStr)
|
||||
}
|
||||
}
|
||||
|
||||
// extracts a URL from the request ctx. If the URL in the request
|
||||
@ -183,7 +188,7 @@ func fetchSite(urlpath string, queries map[string]string) (string, *http.Request
|
||||
|
||||
// Fetch the site
|
||||
client := &http.Client{
|
||||
Timeout: time.Second * 15,
|
||||
Timeout: time.Second * time.Duration(defaultTimeout),
|
||||
}
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user