MCPcopy Create free account
hub / github.com/akash-network/provider / newHTTPWrapperServiceClient

Function newHTTPWrapperServiceClient

cluster/util/service_client.go:26–57  ·  view source on GitHub ↗
(isHTTPS, secure bool, baseURL string)

Source from the content-addressed store, hash-verified

24}
25
26func newHTTPWrapperServiceClient(isHTTPS, secure bool, baseURL string) *httpWrapperServiceClient {
27 netDialer := &net.Dialer{}
28
29 // By default, block both things
30 netDial := func(_ context.Context, network, addr string) (net.Conn, error) {
31 return nil, fmt.Errorf("%w: cannot connect to %v:%v TLS must be used", errServiceClient, network, addr)
32 }
33 dialTLS := func(_ context.Context, network string, addr string) (net.Conn, error) {
34 return nil, fmt.Errorf("%w: cannot connect to %v:%v TLS is not supported", errServiceClient, network, addr)
35 }
36
37 // Unblock one of the dial methods
38 if isHTTPS {
39 tlsDialer := tls.Dialer{
40 NetDialer: netDialer,
41 Config: &tls.Config{
42 InsecureSkipVerify: !secure, // nolint:gosec
43 },
44 }
45 dialTLS = tlsDialer.DialContext
46 } else {
47 netDial = netDialer.DialContext
48 }
49
50 transport := &http.Transport{
51 DialContext: netDial,
52 DialTLSContext: dialTLS,
53 MaxIdleConns: 2,
54 MaxConnsPerHost: 2,
55 }
56 return newHTTPWrapperServiceClientWithTransport(transport, baseURL)
57}
58
59func newHTTPWrapperServiceClientWithTransport(transport http.RoundTripper, baseURL string) *httpWrapperServiceClient {
60 return &httpWrapperServiceClient{

Callers 2

GetClientMethod · 0.85
discoverDNSMethod · 0.85

Tested by

no test coverage detected