Add insecure HTTPS requests to IP addresses

This commit is contained in:
Alexey Khit
2023-08-28 22:29:12 +03:00
parent dc2ab5fcc0
commit 7f232c5cf2
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -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
View File
@@ -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
}