config.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package rest
  14. import (
  15. "context"
  16. "errors"
  17. "fmt"
  18. "io/ioutil"
  19. "net"
  20. "net/http"
  21. "net/url"
  22. "os"
  23. "path/filepath"
  24. gruntime "runtime"
  25. "strings"
  26. "time"
  27. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  28. "k8s.io/apimachinery/pkg/runtime"
  29. "k8s.io/apimachinery/pkg/runtime/schema"
  30. "k8s.io/client-go/pkg/version"
  31. clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
  32. "k8s.io/client-go/transport"
  33. certutil "k8s.io/client-go/util/cert"
  34. "k8s.io/client-go/util/flowcontrol"
  35. "k8s.io/klog/v2"
  36. )
  37. const (
  38. DefaultQPS float32 = 5.0
  39. DefaultBurst int = 10
  40. )
  41. var ErrNotInCluster = errors.New("unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined")
  42. // Config holds the common attributes that can be passed to a Kubernetes client on
  43. // initialization.
  44. type Config struct {
  45. // Host must be a host string, a host:port pair, or a URL to the base of the apiserver.
  46. // If a URL is given then the (optional) Path of that URL represents a prefix that must
  47. // be appended to all request URIs used to access the apiserver. This allows a frontend
  48. // proxy to easily relocate all of the apiserver endpoints.
  49. Host string
  50. // APIPath is a sub-path that points to an API root.
  51. APIPath string
  52. // ContentConfig contains settings that affect how objects are transformed when
  53. // sent to the server.
  54. ContentConfig
  55. // Server requires Basic authentication
  56. Username string
  57. Password string
  58. // Server requires Bearer authentication. This client will not attempt to use
  59. // refresh tokens for an OAuth2 flow.
  60. // TODO: demonstrate an OAuth2 compatible client.
  61. BearerToken string
  62. // Path to a file containing a BearerToken.
  63. // If set, the contents are periodically read.
  64. // The last successfully read value takes precedence over BearerToken.
  65. BearerTokenFile string
  66. // Impersonate is the configuration that RESTClient will use for impersonation.
  67. Impersonate ImpersonationConfig
  68. // Server requires plugin-specified authentication.
  69. AuthProvider *clientcmdapi.AuthProviderConfig
  70. // Callback to persist config for AuthProvider.
  71. AuthConfigPersister AuthProviderConfigPersister
  72. // Exec-based authentication provider.
  73. ExecProvider *clientcmdapi.ExecConfig
  74. // TLSClientConfig contains settings to enable transport layer security
  75. TLSClientConfig
  76. // UserAgent is an optional field that specifies the caller of this request.
  77. UserAgent string
  78. // DisableCompression bypasses automatic GZip compression requests to the
  79. // server.
  80. DisableCompression bool
  81. // Transport may be used for custom HTTP behavior. This attribute may not
  82. // be specified with the TLS client certificate options. Use WrapTransport
  83. // to provide additional per-server middleware behavior.
  84. Transport http.RoundTripper
  85. // WrapTransport will be invoked for custom HTTP behavior after the underlying
  86. // transport is initialized (either the transport created from TLSClientConfig,
  87. // Transport, or http.DefaultTransport). The config may layer other RoundTrippers
  88. // on top of the returned RoundTripper.
  89. //
  90. // A future release will change this field to an array. Use config.Wrap()
  91. // instead of setting this value directly.
  92. WrapTransport transport.WrapperFunc
  93. // QPS indicates the maximum QPS to the master from this client.
  94. // If it's zero, the created RESTClient will use DefaultQPS: 5
  95. QPS float32
  96. // Maximum burst for throttle.
  97. // If it's zero, the created RESTClient will use DefaultBurst: 10.
  98. Burst int
  99. // Rate limiter for limiting connections to the master from this client. If present overwrites QPS/Burst
  100. RateLimiter flowcontrol.RateLimiter
  101. // WarningHandler handles warnings in server responses.
  102. // If not set, the default warning handler is used.
  103. WarningHandler WarningHandler
  104. // The maximum length of time to wait before giving up on a server request. A value of zero means no timeout.
  105. Timeout time.Duration
  106. // Dial specifies the dial function for creating unencrypted TCP connections.
  107. Dial func(ctx context.Context, network, address string) (net.Conn, error)
  108. // Proxy is the the proxy func to be used for all requests made by this
  109. // transport. If Proxy is nil, http.ProxyFromEnvironment is used. If Proxy
  110. // returns a nil *URL, no proxy is used.
  111. //
  112. // socks5 proxying does not currently support spdy streaming endpoints.
  113. Proxy func(*http.Request) (*url.URL, error)
  114. // Version forces a specific version to be used (if registered)
  115. // Do we need this?
  116. // Version string
  117. }
  118. var _ fmt.Stringer = new(Config)
  119. var _ fmt.GoStringer = new(Config)
  120. type sanitizedConfig *Config
  121. type sanitizedAuthConfigPersister struct{ AuthProviderConfigPersister }
  122. func (sanitizedAuthConfigPersister) GoString() string {
  123. return "rest.AuthProviderConfigPersister(--- REDACTED ---)"
  124. }
  125. func (sanitizedAuthConfigPersister) String() string {
  126. return "rest.AuthProviderConfigPersister(--- REDACTED ---)"
  127. }
  128. // GoString implements fmt.GoStringer and sanitizes sensitive fields of Config
  129. // to prevent accidental leaking via logs.
  130. func (c *Config) GoString() string {
  131. return c.String()
  132. }
  133. // String implements fmt.Stringer and sanitizes sensitive fields of Config to
  134. // prevent accidental leaking via logs.
  135. func (c *Config) String() string {
  136. if c == nil {
  137. return "<nil>"
  138. }
  139. cc := sanitizedConfig(CopyConfig(c))
  140. // Explicitly mark non-empty credential fields as redacted.
  141. if cc.Password != "" {
  142. cc.Password = "--- REDACTED ---"
  143. }
  144. if cc.BearerToken != "" {
  145. cc.BearerToken = "--- REDACTED ---"
  146. }
  147. if cc.AuthConfigPersister != nil {
  148. cc.AuthConfigPersister = sanitizedAuthConfigPersister{cc.AuthConfigPersister}
  149. }
  150. return fmt.Sprintf("%#v", cc)
  151. }
  152. // ImpersonationConfig has all the available impersonation options
  153. type ImpersonationConfig struct {
  154. // UserName is the username to impersonate on each request.
  155. UserName string
  156. // Groups are the groups to impersonate on each request.
  157. Groups []string
  158. // Extra is a free-form field which can be used to link some authentication information
  159. // to authorization information. This field allows you to impersonate it.
  160. Extra map[string][]string
  161. }
  162. // +k8s:deepcopy-gen=true
  163. // TLSClientConfig contains settings to enable transport layer security
  164. type TLSClientConfig struct {
  165. // Server should be accessed without verifying the TLS certificate. For testing only.
  166. Insecure bool
  167. // ServerName is passed to the server for SNI and is used in the client to check server
  168. // ceritificates against. If ServerName is empty, the hostname used to contact the
  169. // server is used.
  170. ServerName string
  171. // Server requires TLS client certificate authentication
  172. CertFile string
  173. // Server requires TLS client certificate authentication
  174. KeyFile string
  175. // Trusted root certificates for server
  176. CAFile string
  177. // CertData holds PEM-encoded bytes (typically read from a client certificate file).
  178. // CertData takes precedence over CertFile
  179. CertData []byte
  180. // KeyData holds PEM-encoded bytes (typically read from a client certificate key file).
  181. // KeyData takes precedence over KeyFile
  182. KeyData []byte
  183. // CAData holds PEM-encoded bytes (typically read from a root certificates bundle).
  184. // CAData takes precedence over CAFile
  185. CAData []byte
  186. // NextProtos is a list of supported application level protocols, in order of preference.
  187. // Used to populate tls.Config.NextProtos.
  188. // To indicate to the server http/1.1 is preferred over http/2, set to ["http/1.1", "h2"] (though the server is free to ignore that preference).
  189. // To use only http/1.1, set to ["http/1.1"].
  190. NextProtos []string
  191. }
  192. var _ fmt.Stringer = TLSClientConfig{}
  193. var _ fmt.GoStringer = TLSClientConfig{}
  194. type sanitizedTLSClientConfig TLSClientConfig
  195. // GoString implements fmt.GoStringer and sanitizes sensitive fields of
  196. // TLSClientConfig to prevent accidental leaking via logs.
  197. func (c TLSClientConfig) GoString() string {
  198. return c.String()
  199. }
  200. // String implements fmt.Stringer and sanitizes sensitive fields of
  201. // TLSClientConfig to prevent accidental leaking via logs.
  202. func (c TLSClientConfig) String() string {
  203. cc := sanitizedTLSClientConfig{
  204. Insecure: c.Insecure,
  205. ServerName: c.ServerName,
  206. CertFile: c.CertFile,
  207. KeyFile: c.KeyFile,
  208. CAFile: c.CAFile,
  209. CertData: c.CertData,
  210. KeyData: c.KeyData,
  211. CAData: c.CAData,
  212. NextProtos: c.NextProtos,
  213. }
  214. // Explicitly mark non-empty credential fields as redacted.
  215. if len(cc.CertData) != 0 {
  216. cc.CertData = []byte("--- TRUNCATED ---")
  217. }
  218. if len(cc.KeyData) != 0 {
  219. cc.KeyData = []byte("--- REDACTED ---")
  220. }
  221. return fmt.Sprintf("%#v", cc)
  222. }
  223. type ContentConfig struct {
  224. // AcceptContentTypes specifies the types the client will accept and is optional.
  225. // If not set, ContentType will be used to define the Accept header
  226. AcceptContentTypes string
  227. // ContentType specifies the wire format used to communicate with the server.
  228. // This value will be set as the Accept header on requests made to the server, and
  229. // as the default content type on any object sent to the server. If not set,
  230. // "application/json" is used.
  231. ContentType string
  232. // GroupVersion is the API version to talk to. Must be provided when initializing
  233. // a RESTClient directly. When initializing a Client, will be set with the default
  234. // code version.
  235. GroupVersion *schema.GroupVersion
  236. // NegotiatedSerializer is used for obtaining encoders and decoders for multiple
  237. // supported media types.
  238. //
  239. // TODO: NegotiatedSerializer will be phased out as internal clients are removed
  240. // from Kubernetes.
  241. NegotiatedSerializer runtime.NegotiatedSerializer
  242. }
  243. // RESTClientFor returns a RESTClient that satisfies the requested attributes on a client Config
  244. // object. Note that a RESTClient may require fields that are optional when initializing a Client.
  245. // A RESTClient created by this method is generic - it expects to operate on an API that follows
  246. // the Kubernetes conventions, but may not be the Kubernetes API.
  247. func RESTClientFor(config *Config) (*RESTClient, error) {
  248. if config.GroupVersion == nil {
  249. return nil, fmt.Errorf("GroupVersion is required when initializing a RESTClient")
  250. }
  251. if config.NegotiatedSerializer == nil {
  252. return nil, fmt.Errorf("NegotiatedSerializer is required when initializing a RESTClient")
  253. }
  254. baseURL, versionedAPIPath, err := defaultServerUrlFor(config)
  255. if err != nil {
  256. return nil, err
  257. }
  258. transport, err := TransportFor(config)
  259. if err != nil {
  260. return nil, err
  261. }
  262. var httpClient *http.Client
  263. if transport != http.DefaultTransport {
  264. httpClient = &http.Client{Transport: transport}
  265. if config.Timeout > 0 {
  266. httpClient.Timeout = config.Timeout
  267. }
  268. }
  269. rateLimiter := config.RateLimiter
  270. if rateLimiter == nil {
  271. qps := config.QPS
  272. if config.QPS == 0.0 {
  273. qps = DefaultQPS
  274. }
  275. burst := config.Burst
  276. if config.Burst == 0 {
  277. burst = DefaultBurst
  278. }
  279. if qps > 0 {
  280. rateLimiter = flowcontrol.NewTokenBucketRateLimiter(qps, burst)
  281. }
  282. }
  283. var gv schema.GroupVersion
  284. if config.GroupVersion != nil {
  285. gv = *config.GroupVersion
  286. }
  287. clientContent := ClientContentConfig{
  288. AcceptContentTypes: config.AcceptContentTypes,
  289. ContentType: config.ContentType,
  290. GroupVersion: gv,
  291. Negotiator: runtime.NewClientNegotiator(config.NegotiatedSerializer, gv),
  292. }
  293. restClient, err := NewRESTClient(baseURL, versionedAPIPath, clientContent, rateLimiter, httpClient)
  294. if err == nil && config.WarningHandler != nil {
  295. restClient.warningHandler = config.WarningHandler
  296. }
  297. return restClient, err
  298. }
  299. // UnversionedRESTClientFor is the same as RESTClientFor, except that it allows
  300. // the config.Version to be empty.
  301. func UnversionedRESTClientFor(config *Config) (*RESTClient, error) {
  302. if config.NegotiatedSerializer == nil {
  303. return nil, fmt.Errorf("NegotiatedSerializer is required when initializing a RESTClient")
  304. }
  305. baseURL, versionedAPIPath, err := defaultServerUrlFor(config)
  306. if err != nil {
  307. return nil, err
  308. }
  309. transport, err := TransportFor(config)
  310. if err != nil {
  311. return nil, err
  312. }
  313. var httpClient *http.Client
  314. if transport != http.DefaultTransport {
  315. httpClient = &http.Client{Transport: transport}
  316. if config.Timeout > 0 {
  317. httpClient.Timeout = config.Timeout
  318. }
  319. }
  320. rateLimiter := config.RateLimiter
  321. if rateLimiter == nil {
  322. qps := config.QPS
  323. if config.QPS == 0.0 {
  324. qps = DefaultQPS
  325. }
  326. burst := config.Burst
  327. if config.Burst == 0 {
  328. burst = DefaultBurst
  329. }
  330. if qps > 0 {
  331. rateLimiter = flowcontrol.NewTokenBucketRateLimiter(qps, burst)
  332. }
  333. }
  334. gv := metav1.SchemeGroupVersion
  335. if config.GroupVersion != nil {
  336. gv = *config.GroupVersion
  337. }
  338. clientContent := ClientContentConfig{
  339. AcceptContentTypes: config.AcceptContentTypes,
  340. ContentType: config.ContentType,
  341. GroupVersion: gv,
  342. Negotiator: runtime.NewClientNegotiator(config.NegotiatedSerializer, gv),
  343. }
  344. restClient, err := NewRESTClient(baseURL, versionedAPIPath, clientContent, rateLimiter, httpClient)
  345. if err == nil && config.WarningHandler != nil {
  346. restClient.warningHandler = config.WarningHandler
  347. }
  348. return restClient, err
  349. }
  350. // SetKubernetesDefaults sets default values on the provided client config for accessing the
  351. // Kubernetes API or returns an error if any of the defaults are impossible or invalid.
  352. func SetKubernetesDefaults(config *Config) error {
  353. if len(config.UserAgent) == 0 {
  354. config.UserAgent = DefaultKubernetesUserAgent()
  355. }
  356. return nil
  357. }
  358. // adjustCommit returns sufficient significant figures of the commit's git hash.
  359. func adjustCommit(c string) string {
  360. if len(c) == 0 {
  361. return "unknown"
  362. }
  363. if len(c) > 7 {
  364. return c[:7]
  365. }
  366. return c
  367. }
  368. // adjustVersion strips "alpha", "beta", etc. from version in form
  369. // major.minor.patch-[alpha|beta|etc].
  370. func adjustVersion(v string) string {
  371. if len(v) == 0 {
  372. return "unknown"
  373. }
  374. seg := strings.SplitN(v, "-", 2)
  375. return seg[0]
  376. }
  377. // adjustCommand returns the last component of the
  378. // OS-specific command path for use in User-Agent.
  379. func adjustCommand(p string) string {
  380. // Unlikely, but better than returning "".
  381. if len(p) == 0 {
  382. return "unknown"
  383. }
  384. return filepath.Base(p)
  385. }
  386. // buildUserAgent builds a User-Agent string from given args.
  387. func buildUserAgent(command, version, os, arch, commit string) string {
  388. return fmt.Sprintf(
  389. "%s/%s (%s/%s) kubernetes/%s", command, version, os, arch, commit)
  390. }
  391. // DefaultKubernetesUserAgent returns a User-Agent string built from static global vars.
  392. func DefaultKubernetesUserAgent() string {
  393. return buildUserAgent(
  394. adjustCommand(os.Args[0]),
  395. adjustVersion(version.Get().GitVersion),
  396. gruntime.GOOS,
  397. gruntime.GOARCH,
  398. adjustCommit(version.Get().GitCommit))
  399. }
  400. // InClusterConfig returns a config object which uses the service account
  401. // kubernetes gives to pods. It's intended for clients that expect to be
  402. // running inside a pod running on kubernetes. It will return ErrNotInCluster
  403. // if called from a process not running in a kubernetes environment.
  404. func InClusterConfig() (*Config, error) {
  405. const (
  406. tokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"
  407. rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
  408. )
  409. host, port := os.Getenv("KUBERNETES_SERVICE_HOST"), os.Getenv("KUBERNETES_SERVICE_PORT")
  410. if len(host) == 0 || len(port) == 0 {
  411. return nil, ErrNotInCluster
  412. }
  413. token, err := ioutil.ReadFile(tokenFile)
  414. if err != nil {
  415. return nil, err
  416. }
  417. tlsClientConfig := TLSClientConfig{}
  418. if _, err := certutil.NewPool(rootCAFile); err != nil {
  419. klog.Errorf("Expected to load root CA config from %s, but got err: %v", rootCAFile, err)
  420. } else {
  421. tlsClientConfig.CAFile = rootCAFile
  422. }
  423. return &Config{
  424. // TODO: switch to using cluster DNS.
  425. Host: "https://" + net.JoinHostPort(host, port),
  426. TLSClientConfig: tlsClientConfig,
  427. BearerToken: string(token),
  428. BearerTokenFile: tokenFile,
  429. }, nil
  430. }
  431. // IsConfigTransportTLS returns true if and only if the provided
  432. // config will result in a protected connection to the server when it
  433. // is passed to restclient.RESTClientFor(). Use to determine when to
  434. // send credentials over the wire.
  435. //
  436. // Note: the Insecure flag is ignored when testing for this value, so MITM attacks are
  437. // still possible.
  438. func IsConfigTransportTLS(config Config) bool {
  439. baseURL, _, err := defaultServerUrlFor(&config)
  440. if err != nil {
  441. return false
  442. }
  443. return baseURL.Scheme == "https"
  444. }
  445. // LoadTLSFiles copies the data from the CertFile, KeyFile, and CAFile fields into the CertData,
  446. // KeyData, and CAFile fields, or returns an error. If no error is returned, all three fields are
  447. // either populated or were empty to start.
  448. func LoadTLSFiles(c *Config) error {
  449. var err error
  450. c.CAData, err = dataFromSliceOrFile(c.CAData, c.CAFile)
  451. if err != nil {
  452. return err
  453. }
  454. c.CertData, err = dataFromSliceOrFile(c.CertData, c.CertFile)
  455. if err != nil {
  456. return err
  457. }
  458. c.KeyData, err = dataFromSliceOrFile(c.KeyData, c.KeyFile)
  459. if err != nil {
  460. return err
  461. }
  462. return nil
  463. }
  464. // dataFromSliceOrFile returns data from the slice (if non-empty), or from the file,
  465. // or an error if an error occurred reading the file
  466. func dataFromSliceOrFile(data []byte, file string) ([]byte, error) {
  467. if len(data) > 0 {
  468. return data, nil
  469. }
  470. if len(file) > 0 {
  471. fileData, err := ioutil.ReadFile(file)
  472. if err != nil {
  473. return []byte{}, err
  474. }
  475. return fileData, nil
  476. }
  477. return nil, nil
  478. }
  479. func AddUserAgent(config *Config, userAgent string) *Config {
  480. fullUserAgent := DefaultKubernetesUserAgent() + "/" + userAgent
  481. config.UserAgent = fullUserAgent
  482. return config
  483. }
  484. // AnonymousClientConfig returns a copy of the given config with all user credentials (cert/key, bearer token, and username/password) and custom transports (WrapTransport, Transport) removed
  485. func AnonymousClientConfig(config *Config) *Config {
  486. // copy only known safe fields
  487. return &Config{
  488. Host: config.Host,
  489. APIPath: config.APIPath,
  490. ContentConfig: config.ContentConfig,
  491. TLSClientConfig: TLSClientConfig{
  492. Insecure: config.Insecure,
  493. ServerName: config.ServerName,
  494. CAFile: config.TLSClientConfig.CAFile,
  495. CAData: config.TLSClientConfig.CAData,
  496. NextProtos: config.TLSClientConfig.NextProtos,
  497. },
  498. RateLimiter: config.RateLimiter,
  499. WarningHandler: config.WarningHandler,
  500. UserAgent: config.UserAgent,
  501. DisableCompression: config.DisableCompression,
  502. QPS: config.QPS,
  503. Burst: config.Burst,
  504. Timeout: config.Timeout,
  505. Dial: config.Dial,
  506. Proxy: config.Proxy,
  507. }
  508. }
  509. // CopyConfig returns a copy of the given config
  510. func CopyConfig(config *Config) *Config {
  511. return &Config{
  512. Host: config.Host,
  513. APIPath: config.APIPath,
  514. ContentConfig: config.ContentConfig,
  515. Username: config.Username,
  516. Password: config.Password,
  517. BearerToken: config.BearerToken,
  518. BearerTokenFile: config.BearerTokenFile,
  519. Impersonate: ImpersonationConfig{
  520. Groups: config.Impersonate.Groups,
  521. Extra: config.Impersonate.Extra,
  522. UserName: config.Impersonate.UserName,
  523. },
  524. AuthProvider: config.AuthProvider,
  525. AuthConfigPersister: config.AuthConfigPersister,
  526. ExecProvider: config.ExecProvider,
  527. TLSClientConfig: TLSClientConfig{
  528. Insecure: config.TLSClientConfig.Insecure,
  529. ServerName: config.TLSClientConfig.ServerName,
  530. CertFile: config.TLSClientConfig.CertFile,
  531. KeyFile: config.TLSClientConfig.KeyFile,
  532. CAFile: config.TLSClientConfig.CAFile,
  533. CertData: config.TLSClientConfig.CertData,
  534. KeyData: config.TLSClientConfig.KeyData,
  535. CAData: config.TLSClientConfig.CAData,
  536. NextProtos: config.TLSClientConfig.NextProtos,
  537. },
  538. UserAgent: config.UserAgent,
  539. DisableCompression: config.DisableCompression,
  540. Transport: config.Transport,
  541. WrapTransport: config.WrapTransport,
  542. QPS: config.QPS,
  543. Burst: config.Burst,
  544. RateLimiter: config.RateLimiter,
  545. WarningHandler: config.WarningHandler,
  546. Timeout: config.Timeout,
  547. Dial: config.Dial,
  548. Proxy: config.Proxy,
  549. }
  550. }