Skip to content

Commit

Permalink
fix: remove address cache (#1826)
Browse files Browse the repository at this point in the history
Co-authored-by: adriannajera <adrian@noreply.com>
  • Loading branch information
adriangitvitz and adriannajera committed Oct 25, 2023
1 parent d653dc1 commit 1345285
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions api/client-admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"net"
"net/http"
"net/url"
"sync"
"time"

"github.com/minio/madmin-go/v2"
Expand Down Expand Up @@ -464,15 +463,6 @@ func (ac AdminClient) verifyTierStatus(ctx context.Context, tierName string) err
return ac.Client.VerifyTier(ctx, tierName)
}

// httpClient is a custom http client, this client should not be called directly and instead be
// called using GetConsoleHTTPClient() to ensure is initialized and the certificates are loaded correctly
var httpClients = struct {
sync.Mutex
m map[string]*http.Client
}{
m: make(map[string]*http.Client),
}

// isLocalAddress returns true if the url contains an IPv4/IPv6 hostname
// that points to the local machine - FQDN are not supported
func isLocalIPAddress(ipAddr string) bool {
Expand All @@ -492,17 +482,8 @@ func GetConsoleHTTPClient(address string) *http.Client {
address = u.Hostname()
}

httpClients.Lock()
client, ok := httpClients.m[address]
httpClients.Unlock()
if ok {
return client
}
client := PrepareConsoleHTTPClient(isLocalIPAddress(address))

client = PrepareConsoleHTTPClient(isLocalIPAddress(address))
httpClients.Lock()
httpClients.m[address] = client
httpClients.Unlock()
return client
}

Expand Down

0 comments on commit 1345285

Please sign in to comment.