Add extensive endpoints validation (#4019)

This commit is contained in:
Bala FA
2017-04-12 04:14:27 +05:30
committed by Harshavardhana
parent 1b1b9e4801
commit de204a0a52
48 changed files with 1432 additions and 2269 deletions

View File

@@ -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.