Add insecure HTTPS requests to IP addresses
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ func Dial(u *url.URL, port string, timeout time.Duration) (net.Conn, error) {
|
||||
switch u.Scheme {
|
||||
case "rtsp", "rtmp":
|
||||
case "rtsps", "rtspx", "rtmps", "rtmpx":
|
||||
if u.Scheme[4] == 'x' || net.ParseIP(hostname) != nil {
|
||||
if u.Scheme[4] == 'x' || IsIP(hostname) {
|
||||
secure = &tls.Config{InsecureSkipVerify: true}
|
||||
} else {
|
||||
secure = &tls.Config{ServerName: hostname}
|
||||
|
||||
+5
-1
@@ -32,7 +32,7 @@ func Do(req *http.Request) (*http.Response, error) {
|
||||
|
||||
var client *http.Client
|
||||
|
||||
if req.URL.Scheme == "httpx" {
|
||||
if req.URL.Scheme == "httpx" || (req.URL.Scheme == "https" && IsIP(req.URL.Hostname())) {
|
||||
req.URL.Scheme = "https"
|
||||
|
||||
if insecureClient == nil {
|
||||
@@ -125,3 +125,7 @@ func Close(res *http.Response) {
|
||||
_ = res.Body.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func IsIP(hostname string) bool {
|
||||
return net.ParseIP(hostname) != nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user