5 Commits

Author SHA1 Message Date
mms-gianni
3918cf39ac Merge pull request #64 from lutfuahmet/main
HTTP Timeout
2023-12-07 09:37:24 +01:00
ahmetlutfu
92b5233257 overriding default timeout via HTTP_TIMEOUT env variable. 2023-12-06 23:11:58 +03:00
ahmetlutfu
a849603d8b added timeout for http client 2023-12-06 23:07:52 +03:00
Kevin Pham
f78c958334 Merge pull request #57 from jgillies/change-form-type
Change form type to url
2023-12-03 21:33:11 -06:00
Jesse Gillies
d6925e53c2 change form type to url 2023-12-03 21:10:43 -05:00
2 changed files with 11 additions and 3 deletions

View File

@@ -19,7 +19,7 @@
</header> </header>
<form id="inputForm" method="get" class="mx-4 relative"> <form id="inputForm" method="get" class="mx-4 relative">
<div> <div>
<input type="text" id="inputField" placeholder="Proxy Search" name="inputField" class="w-full text-sm leading-6 text-slate-400 rounded-md ring-1 ring-slate-900/10 shadow-sm py-1.5 pl-2 pr-3 hover:ring-slate-300 dark:bg-slate-800 dark:highlight-white/5 dark:hover:bg-slate-700" required autofocus> <input type="url" id="inputField" placeholder="Proxy Search" name="inputField" class="w-full text-sm leading-6 text-slate-400 rounded-md ring-1 ring-slate-900/10 shadow-sm py-1.5 pl-2 pr-3 hover:ring-slate-300 dark:bg-slate-800 dark:highlight-white/5 dark:hover:bg-slate-700" required autofocus>
<button id="clearButton" type="button" aria-label="Clear Search" title="Clear Search" class="hidden absolute inset-y-0 right-0 items-center pr-2 hover:text-slate-400 hover:dark:text-slate-300" tabindex="-1"> <button id="clearButton" type="button" aria-label="Clear Search" title="Clear Search" class="hidden absolute inset-y-0 right-0 items-center pr-2 hover:text-slate-400 hover:dark:text-slate-300" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round""><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round""><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
</button> </button>
@@ -76,4 +76,4 @@
</style> </style>
</body> </body>
</html> </html>

View File

@@ -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 != "" {