Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
f49eadc0
Commit
f49eadc0
authored
5 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
fixed some various log messages around connection
parent
03910933
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/client.go
+10
-8
10 additions, 8 deletions
api/client.go
cmd/root.go
+0
-3
0 additions, 3 deletions
cmd/root.go
with
10 additions
and
11 deletions
api/client.go
+
10
−
8
View file @
f49eadc0
...
@@ -149,41 +149,43 @@ func NewClient(s globals.Storage, loc string, ndfJSON *ndf.NetworkDefinition) (*
...
@@ -149,41 +149,43 @@ 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 %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 %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"
)
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
))
}
}
}
else
{
}
else
{
globals
.
Log
.
WARN
.
Printf
(
"Unable to find registration server"
)
globals
.
Log
.
WARN
.
Printf
(
"Unable to find registration server
!
"
)
}
}
return
nil
return
err
}
}
// Registers user and returns the User ID.
// Registers user and returns the User ID.
...
...
This diff is collapsed.
Click to expand it.
cmd/root.go
+
0
−
3
View file @
f49eadc0
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment