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 {
|
switch u.Scheme {
|
||||||
case "rtsp", "rtmp":
|
case "rtsp", "rtmp":
|
||||||
case "rtsps", "rtspx", "rtmps", "rtmpx":
|
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}
|
secure = &tls.Config{InsecureSkipVerify: true}
|
||||||
} else {
|
} else {
|
||||||
secure = &tls.Config{ServerName: hostname}
|
secure = &tls.Config{ServerName: hostname}
|
||||||
|
|||||||
+5
-1
@@ -32,7 +32,7 @@ func Do(req *http.Request) (*http.Response, error) {
|
|||||||
|
|
||||||
var client *http.Client
|
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"
|
req.URL.Scheme = "https"
|
||||||
|
|
||||||
if insecureClient == nil {
|
if insecureClient == nil {
|
||||||
@@ -125,3 +125,7 @@ func Close(res *http.Response) {
|
|||||||
_ = res.Body.Close()
|
_ = res.Body.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsIP(hostname string) bool {
|
||||||
|
return net.ParseIP(hostname) != nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user