mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 16:24:03 +03:00
Add PatchHTTPClient method
This method is mostly required for testing
This commit is contained in:
@@ -80,6 +80,8 @@ func (c *cliCommandAccess) getIP(protocol string) net.IP {
|
||||
},
|
||||
}
|
||||
|
||||
c.network.PatchHTTPClient(client)
|
||||
|
||||
resp, err := client.Get("https://ifconfig.co") // nolint: bodyclose, noctx
|
||||
if err != nil {
|
||||
return nil
|
||||
|
||||
@@ -39,4 +39,5 @@ type Network interface {
|
||||
DNSResolve(network, hostname string) (ips []string, err error)
|
||||
MakeHTTPClient(timeout time.Duration) *http.Client
|
||||
IdleTimeout() time.Duration
|
||||
PatchHTTPClient(*http.Client)
|
||||
}
|
||||
|
||||
@@ -120,6 +120,9 @@ func (n *network) MakeHTTPClient(timeout time.Duration) *http.Client {
|
||||
}
|
||||
}
|
||||
|
||||
func (n *network) PatchHTTPClient(_ *http.Client) {
|
||||
}
|
||||
|
||||
func NewNetwork(dialer Dialer, dohHostname string, idleTimeout time.Duration) (Network, error) {
|
||||
switch {
|
||||
case idleTimeout < 0:
|
||||
|
||||
Reference in New Issue
Block a user