mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
parent
2b504f17de
commit
63c36e2e69
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/procutil"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/procutil"
|
||||||
"github.com/VictoriaMetrics/fasthttp"
|
|
||||||
"github.com/VictoriaMetrics/metrics"
|
"github.com/VictoriaMetrics/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -283,21 +282,15 @@ func getTLSConfig(certFile, keyFile, CAFile, serverName *string, insecureSkipVer
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getTransport(URL, certFile, keyFile, CAFile, serverName *string, insecureSkipVerify *bool) (*http.Transport, error) {
|
func getTransport(URL, certFile, keyFile, CAFile, serverName *string, insecureSkipVerify *bool) (*http.Transport, error) {
|
||||||
var u fasthttp.URI
|
t := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
u.Update(*URL)
|
if !strings.HasPrefix(*URL, "https") {
|
||||||
|
return t, nil
|
||||||
var t *http.Transport
|
}
|
||||||
if string(u.Scheme()) == "https" {
|
|
||||||
t = http.DefaultTransport.(*http.Transport).Clone()
|
|
||||||
|
|
||||||
tlsCfg, err := getTLSConfig(certFile, keyFile, CAFile, serverName, insecureSkipVerify)
|
tlsCfg, err := getTLSConfig(certFile, keyFile, CAFile, serverName, insecureSkipVerify)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
t.TLSClientConfig = tlsCfg
|
t.TLSClientConfig = tlsCfg
|
||||||
}
|
|
||||||
|
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,15 +87,12 @@ func TestGetTransport(t *testing.T) {
|
|||||||
var certFile, keyFile, CAFile, serverName string
|
var certFile, keyFile, CAFile, serverName string
|
||||||
var insecureSkipVerify bool
|
var insecureSkipVerify bool
|
||||||
URL := "http://victoriametrics.com"
|
URL := "http://victoriametrics.com"
|
||||||
tr, err := getTransport(&URL, &certFile, &keyFile, &CAFile, &serverName, &insecureSkipVerify)
|
_, err := getTransport(&URL, &certFile, &keyFile, &CAFile, &serverName, &insecureSkipVerify)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error %s", err)
|
t.Errorf("unexpected error %s", err)
|
||||||
}
|
}
|
||||||
if tr != nil {
|
|
||||||
t.Errorf("expected Transport to be nil, got %v", tr)
|
|
||||||
}
|
|
||||||
URL = "https://victoriametrics.com"
|
URL = "https://victoriametrics.com"
|
||||||
tr, err = getTransport(&URL, &certFile, &keyFile, &CAFile, &serverName, &insecureSkipVerify)
|
tr, err := getTransport(&URL, &certFile, &keyFile, &CAFile, &serverName, &insecureSkipVerify)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error %s", err)
|
t.Errorf("unexpected error %s", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user