Skip to content

Commit

Permalink
fixed spacing
Browse files Browse the repository at this point in the history
Signed-off-by: SirCocas <sofiateixeiravaz@ua.pt>
  • Loading branch information
SirCocas committed May 10, 2023
1 parent ea266a8 commit e67a121
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,21 @@ func newUnixSocketClient(ctx context.Context, config *Config) (*Client, error) {
}, nil
}

func newNetworkClient(ctx context.Context, config *Config) (*Client, error) { //problem somewhere here
func newNetworkClient(ctx context.Context, config *Config) (*Client, error) {

certificate, err := tls.LoadX509KeyPair(
config.CertFile,
config.KeyFile,
config.CertFile,
config.KeyFile,
)


if err != nil {
return nil, fmt.Errorf("error loading the X.509 key pair: %v", err)
}


if(config.GRPCAuth){
certPool := x509.NewCertPool()
rootCA, err := ioutil.ReadFile(config.CARootFile)


if err != nil {
return nil, fmt.Errorf("error reading the CA Root file certificate: %v", err)
}

ok := certPool.AppendCertsFromPEM(rootCA)
if !ok {
return nil, fmt.Errorf("error appending the root CA to the certificate pool")
Expand All @@ -89,13 +82,10 @@ func newNetworkClient(ctx context.Context, config *Config) (*Client, error) { /
RootCAs: certPool,
})
dialOptions := append(config.DialOptions, grpc.WithTransportCredentials(transportCreds))

conn, err := grpc.DialContext(ctx, fmt.Sprintf(targetFormat, config.Hostname, config.Port), dialOptions...)

if err != nil {
return nil, fmt.Errorf("error dialing server: %v", err)
}

return &Client{
conn: conn,
}, nil
Expand All @@ -107,19 +97,13 @@ func newNetworkClient(ctx context.Context, config *Config) (*Client, error) { /

})
dialOptions := append(config.DialOptions, grpc.WithTransportCredentials(transportCreds))

conn, err := grpc.DialContext(ctx, fmt.Sprintf(targetFormat, config.Hostname, config.Port), dialOptions...)

if err != nil {
return nil, fmt.Errorf("error dialing server: %v", err)
}

return &Client{
conn: conn,
}, nil



}


Expand Down

0 comments on commit e67a121

Please sign in to comment.