Skip to content

Commit

Permalink
follow-up: remove changes for TLS client
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Chen <[email protected]>
  • Loading branch information
Nahemah1022 committed Aug 23, 2024
1 parent 8107a3b commit 6c09796
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 20 deletions.
12 changes: 4 additions & 8 deletions ais/backend/ais.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (m *AISbp) GetInfoInternal() (res meta.RemAisVec) {
func (m *AISbp) GetInfo(clusterConf cmn.BackendConfAIS) (res meta.RemAisVec) {
var (
cfg = cmn.GCO.Get()
cliPlain, cliTLS = remaisClients(&cfg.ClusterConfig)
cliPlain, cliTLS = remaisClients(&cfg.Client)
)
m.mu.RLock()
res.A = make([]*meta.RemAis, 0, len(m.remote))
Expand Down Expand Up @@ -245,12 +245,8 @@ func (m *AISbp) GetInfo(clusterConf cmn.BackendConfAIS) (res meta.RemAisVec) {
return
}

func remaisClients(cfg *cmn.ClusterConfig) (client, clientTLS *http.Client) {
sargs := cfg.Net.HTTP.ToTLS()
if cfg.Net.HTTP.UseHTTPS {
return cmn.NewDefaultClients(cfg.Client.Timeout.D(), &sargs)
}
return cmn.NewDefaultClients(cfg.Client.Timeout.D(), nil)
func remaisClients(clientConf *cmn.ClientConf) (client, clientTLS *http.Client) {
return cmn.NewDefaultClients(clientConf.Timeout.D())
}

// A list of remote AIS URLs can contains both HTTP and HTTPS links at the
Expand All @@ -261,7 +257,7 @@ func (r *remAis) init(alias string, confURLs []string, cfg *cmn.ClusterConfig) (
var (
url string
remSmap, smap *meta.Smap
cliH, cliTLS = remaisClients(cfg)
cliH, cliTLS = remaisClients(&cfg.Client)
)
for _, u := range confURLs {
client := cliH
Expand Down
2 changes: 1 addition & 1 deletion ais/backend/ht.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewHT(t core.TargetPut, config *cmn.Config, tstats stats.Tracker) (core.Bac
t: t,
base: base{provider: apc.HT},
}
bp.cliH, bp.cliTLS = cmn.NewDefaultClients(config.Client.TimeoutLong.D(), nil)
bp.cliH, bp.cliTLS = cmn.NewDefaultClients(config.Client.TimeoutLong.D())
bp.init(t.Snode(), tstats)
return bp, nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/authn/mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func newMgr(driver kvdb.Driver) (m *mgr, err error) {
m = &mgr{
db: driver,
}
m.clientH, m.clientTLS = cmn.NewDefaultClients(time.Duration(Conf.Timeout.Default), nil)
m.clientH, m.clientTLS = cmn.NewDefaultClients(time.Duration(Conf.Timeout.Default))
err = initializeDB(driver)
return
}
Expand Down
10 changes: 2 additions & 8 deletions cmn/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,9 @@ func NewTLS(sargs TLSArgs) (tlsConf *tls.Config, _ error) {
return tlsConf, nil
}

// NewDefaultClients creates and returns a pair of HTTP clients: one without TLS and one with TLS.
// If the provided TLSArgs (sargs) is nil, the clientTLS will be a standard HTTP client without TLS.
func NewDefaultClients(timeout time.Duration, sargs *TLSArgs) (clientH, clientTLS *http.Client) {
func NewDefaultClients(timeout time.Duration) (clientH, clientTLS *http.Client) {
clientH = NewClient(TransportArgs{Timeout: timeout})
if sargs != nil {
clientTLS = NewClientTLS(TransportArgs{Timeout: timeout}, *sargs)
} else {
clientTLS = NewClient(TransportArgs{Timeout: timeout})
}
clientTLS = NewClientTLS(TransportArgs{Timeout: timeout}, TLSArgs{SkipVerify: true})
return
}

Expand Down
1 change: 0 additions & 1 deletion cmn/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ type (
UseHTTPS bool `json:"use_https"` // use HTTPS
SkipVerifyCrt bool `json:"skip_verify"` // skip X509 cert verification (used with self-signed certs)
Chunked bool `json:"chunked_transfer"` // (https://tools.ietf.org/html/rfc7230#page-36; not used since 02/23)
Port int `json:"port"` // AuthN port
}
HTTPConfToSet struct {
Certificate *string `json:"server_crt,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion ext/dload/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type (
var g global

func Init(tstats stats.Tracker, db kvdb.Driver, clientConf *cmn.ClientConf) {
g.clientH, g.clientTLS = cmn.NewDefaultClients(clientConf.TimeoutLong.D(), nil)
g.clientH, g.clientTLS = cmn.NewDefaultClients(clientConf.TimeoutLong.D())

if db == nil { // unit tests only
return
Expand Down

0 comments on commit 6c09796

Please sign in to comment.