Sfoglia il codice sorgente

Add PatchHTTPClient method

This method is mostly required for testing
tags/v2.0.0-rc1
9seconds 5 anni fa
parent
commit
757ea5b63c
3 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  1. 2
    0
      cli_access.go
  2. 1
    0
      mtglib/network/init.go
  3. 3
    0
      mtglib/network/network.go

+ 2
- 0
cli_access.go Vedi File

@@ -80,6 +80,8 @@ func (c *cliCommandAccess) getIP(protocol string) net.IP {
80 80
 		},
81 81
 	}
82 82
 
83
+	c.network.PatchHTTPClient(client)
84
+
83 85
 	resp, err := client.Get("https://ifconfig.co") // nolint: bodyclose, noctx
84 86
 	if err != nil {
85 87
 		return nil

+ 1
- 0
mtglib/network/init.go Vedi File

@@ -39,4 +39,5 @@ type Network interface {
39 39
 	DNSResolve(network, hostname string) (ips []string, err error)
40 40
 	MakeHTTPClient(timeout time.Duration) *http.Client
41 41
 	IdleTimeout() time.Duration
42
+	PatchHTTPClient(*http.Client)
42 43
 }

+ 3
- 0
mtglib/network/network.go Vedi File

@@ -120,6 +120,9 @@ func (n *network) MakeHTTPClient(timeout time.Duration) *http.Client {
120 120
 	}
121 121
 }
122 122
 
123
+func (n *network) PatchHTTPClient(_ *http.Client) {
124
+}
125
+
123 126
 func NewNetwork(dialer Dialer, dohHostname string, idleTimeout time.Duration) (Network, error) {
124 127
 	switch {
125 128
 	case idleTimeout < 0:

Loading…
Annulla
Salva