TUN-1550: Add validation timeout for non-responsive origins

This commit is contained in:
Nick Vollmar
2019-02-27 16:47:00 -06:00
parent 073c5bfdaa
commit 6ca642e572
2 changed files with 37 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import (
"net"
"net/url"
"strings"
"time"
"net/http"
@@ -14,7 +15,10 @@ import (
const defaultScheme = "http"
var supportedProtocol = [2]string{"http", "https"}
var (
supportedProtocol = [2]string{"http", "https"}
validationTimeout = time.Duration(30 * time.Second)
)
func ValidateHostname(hostname string) (string, error) {
if hostname == "" {
@@ -149,6 +153,7 @@ func ValidateHTTPService(originURL string, hostname string, transport http.Round
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
Timeout: validationTimeout,
}
initialRequest, err := http.NewRequest("GET", parsedURL.String(), nil)