Skip to content
Snippets Groups Projects
Commit 2087dfe4 authored by Jake Taylor's avatar Jake Taylor :lips:
Browse files

Merge branch 'logFixes' into 'release'

fixed some various log messages around connection

See merge request !182
parents 03910933 e2eb9698
No related branches found
No related tags found
No related merge requests found
...@@ -149,41 +149,50 @@ func NewClient(s globals.Storage, loc string, ndfJSON *ndf.NetworkDefinition) (* ...@@ -149,41 +149,50 @@ func NewClient(s globals.Storage, loc string, ndfJSON *ndf.NetworkDefinition) (*
// using TLS filepaths to create credential information // using TLS filepaths to create credential information
// for connection establishment // for connection establishment
func (cl *Client) Connect() error { func (cl *Client) Connect() error {
var err error
if len(cl.ndf.Gateways) < 1 { if len(cl.ndf.Gateways) < 1 {
globals.Log.ERROR.Printf("Connect: Invalid number of nodes")
return errors.New("could not connect due to invalid number of nodes") return errors.New("could not connect due to invalid number of nodes")
} }
// connect to all gateways // connect to all gateways
for i, gateway := range cl.ndf.Gateways { for i, gateway := range cl.ndf.Gateways {
var gwCreds []byte var gwCreds []byte
var err error
if gateway.TlsCertificate != "" { if gateway.TlsCertificate != "" {
gwCreds = []byte(gateway.TlsCertificate) gwCreds = []byte(gateway.TlsCertificate)
} }
gwID := id.NewNodeFromBytes(cl.ndf.Nodes[i].ID).NewGateway() gwID := id.NewNodeFromBytes(cl.ndf.Nodes[i].ID).NewGateway()
globals.Log.INFO.Printf("Connecting to gateway at %s...",
gateway.Address)
err = (cl.comm).(*io.Messaging).Comms.ConnectToGateway(gwID, gateway.Address, gwCreds) err = (cl.comm).(*io.Messaging).Comms.ConnectToGateway(gwID, gateway.Address, gwCreds)
if err != nil { if err != nil {
globals.Log.ERROR.Printf("Failed to connect to gateway %s: %+v", gateway.Address, err) return errors.New(fmt.Sprintf("Failed to connect to gateway %s: %+v",
gateway.Address, err))
} }
globals.Log.INFO.Printf("Connected to gateway at %v successfully!",
gateway.Address)
} }
//connect to the registration server //connect to the registration server
if cl.ndf.Registration.Address != "" { if cl.ndf.Registration.Address != "" {
var regCert []byte var regCert []byte
var err error
if cl.ndf.Registration.TlsCertificate != "" { if cl.ndf.Registration.TlsCertificate != "" {
regCert = []byte(cl.ndf.Registration.TlsCertificate) regCert = []byte(cl.ndf.Registration.TlsCertificate)
} }
addr := io.ConnAddr("registration") addr := io.ConnAddr("registration")
globals.Log.INFO.Printf("Connecting to permissioning at %s...",
cl.ndf.Registration.Address)
err = (cl.comm).(*io.Messaging).Comms.ConnectToRegistration(addr, cl.ndf.Registration.Address, regCert) err = (cl.comm).(*io.Messaging).Comms.ConnectToRegistration(addr, cl.ndf.Registration.Address, regCert)
if err != nil { if err != nil {
globals.Log.ERROR.Printf("Failed connecting to permissioning: %+v", err) return errors.New(fmt.Sprintf(
"Failed connecting to permissioning: %+v", err))
} }
globals.Log.INFO.Printf(
"Connected to permissioning at %v successfully!",
cl.ndf.Registration.Address)
} else { } else {
globals.Log.WARN.Printf("Unable to find registration server") globals.Log.WARN.Printf("Unable to find permissioning server!")
} }
return nil return err
} }
// Registers user and returns the User ID. // Registers user and returns the User ID.
...@@ -443,10 +452,6 @@ func (cl *Client) Login(UID *id.User) (string, error) { ...@@ -443,10 +452,6 @@ func (cl *Client) Login(UID *id.User) (string, error) {
return "", err return "", err
} }
if session == nil {
return "", errors.New("Unable to load session: " + err.Error())
}
cl.session = session cl.session = session
return cl.session.GetCurrentUser().Nick, nil return cl.session.GetCurrentUser().Nick, nil
} }
......
...@@ -150,13 +150,10 @@ func sessionInitialization() (*id.User, string, *api.Client) { ...@@ -150,13 +150,10 @@ func sessionInitialization() (*id.User, string, *api.Client) {
} }
// Connect to gateways and reg server // Connect to gateways and reg server
globals.Log.INFO.Println("Connecting...")
err = client.Connect() err = client.Connect()
if err != nil { if err != nil {
globals.Log.FATAL.Panicf("Could not call connect on client: %+v", err) globals.Log.FATAL.Panicf("Could not call connect on client: %+v", err)
} }
globals.Log.INFO.Println("Connected!")
// Holds the User ID // Holds the User ID
var uid *id.User var uid *id.User
...@@ -622,7 +619,6 @@ func initLog() { ...@@ -622,7 +619,6 @@ func initLog() {
// specified from the commandline. // specified from the commandline.
func overwriteNDF(n *ndf.NetworkDefinition) { func overwriteNDF(n *ndf.NetworkDefinition) {
if len(ndfRegistration) == 3 { if len(ndfRegistration) == 3 {
n.Registration.DsaPublicKey = ndfRegistration[0]
n.Registration.Address = ndfRegistration[1] n.Registration.Address = ndfRegistration[1]
n.Registration.TlsCertificate = ndfRegistration[2] n.Registration.TlsCertificate = ndfRegistration[2]
...@@ -637,7 +633,6 @@ func overwriteNDF(n *ndf.NetworkDefinition) { ...@@ -637,7 +633,6 @@ func overwriteNDF(n *ndf.NetworkDefinition) {
} }
n.UDB.ID = udbIdString n.UDB.ID = udbIdString
n.UDB.DsaPublicKey = ndfUDB[1]
globals.Log.WARN.Println("Overwrote UDB values in the " + globals.Log.WARN.Println("Overwrote UDB values in the " +
"NetworkDefinition from the commandline") "NetworkDefinition from the commandline")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment