mirror of
https://github.com/minio/minio.git
synced 2025-12-01 13:52:34 -05:00
Add extensive endpoints validation (#4019)
This commit is contained in:
@@ -21,7 +21,6 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"net/rpc"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@@ -96,39 +95,22 @@ func toStorageErr(err error) error {
|
||||
}
|
||||
|
||||
// Initialize new storage rpc client.
|
||||
func newStorageRPC(ep *url.URL) (StorageAPI, error) {
|
||||
if ep == nil {
|
||||
return nil, errInvalidArgument
|
||||
}
|
||||
|
||||
func newStorageRPC(endpoint Endpoint) StorageAPI {
|
||||
// Dial minio rpc storage http path.
|
||||
rpcPath := path.Join(minioReservedBucketPath, storageRPCPath, getPath(ep))
|
||||
rpcAddr := ep.Host
|
||||
|
||||
rpcPath := path.Join(minioReservedBucketPath, storageRPCPath, endpoint.Path)
|
||||
serverCred := serverConfig.GetCredential()
|
||||
accessKey := serverCred.AccessKey
|
||||
secretKey := serverCred.SecretKey
|
||||
if ep.User != nil {
|
||||
accessKey = ep.User.Username()
|
||||
if password, ok := ep.User.Password(); ok {
|
||||
secretKey = password
|
||||
}
|
||||
}
|
||||
|
||||
storageAPI := &networkStorage{
|
||||
return &networkStorage{
|
||||
rpcClient: newAuthRPCClient(authConfig{
|
||||
accessKey: accessKey,
|
||||
secretKey: secretKey,
|
||||
serverAddr: rpcAddr,
|
||||
accessKey: serverCred.AccessKey,
|
||||
secretKey: serverCred.SecretKey,
|
||||
serverAddr: endpoint.Host,
|
||||
serviceEndpoint: rpcPath,
|
||||
secureConn: globalIsSSL,
|
||||
serviceName: "Storage",
|
||||
disableReconnect: true,
|
||||
}),
|
||||
}
|
||||
|
||||
// Returns successfully here.
|
||||
return storageAPI, nil
|
||||
}
|
||||
|
||||
// Stringer interface compatible representation of network device.
|
||||
|
||||
Reference in New Issue
Block a user