Compare commits
3 Commits
proxy_v2_i
...
v0.0.21
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3918cf39ac | ||
|
|
92b5233257 | ||
|
|
a849603d8b |
@@ -8,7 +8,9 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"ladder/pkg/ruleset"
|
"ladder/pkg/ruleset"
|
||||||
|
|
||||||
@@ -21,6 +23,7 @@ var (
|
|||||||
ForwardedFor = getenv("X_FORWARDED_FOR", "66.249.66.1")
|
ForwardedFor = getenv("X_FORWARDED_FOR", "66.249.66.1")
|
||||||
rulesSet = ruleset.NewRulesetFromEnv()
|
rulesSet = ruleset.NewRulesetFromEnv()
|
||||||
allowedDomains = []string{}
|
allowedDomains = []string{}
|
||||||
|
defaultTimeout = 15 // in seconds
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -28,6 +31,9 @@ func init() {
|
|||||||
if os.Getenv("ALLOWED_DOMAINS_RULESET") == "true" {
|
if os.Getenv("ALLOWED_DOMAINS_RULESET") == "true" {
|
||||||
allowedDomains = append(allowedDomains, rulesSet.Domains()...)
|
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
|
// extracts a URL from the request ctx. If the URL in the request
|
||||||
@@ -181,7 +187,9 @@ func fetchSite(urlpath string, queries map[string]string) (string, *http.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the site
|
// Fetch the site
|
||||||
client := &http.Client{}
|
client := &http.Client{
|
||||||
|
Timeout: time.Second * time.Duration(defaultTimeout),
|
||||||
|
}
|
||||||
req, _ := http.NewRequest("GET", url, nil)
|
req, _ := http.NewRequest("GET", url, nil)
|
||||||
|
|
||||||
if rule.Headers.UserAgent != "" {
|
if rule.Headers.UserAgent != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user