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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
395fa282
Commit
395fa282
authored
May 9, 2022
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Clean up authenticated package/
parent
1d25fdae
No related branches found
No related tags found
3 merge requests
!510
Release
,
!216
Xx 3895/authenticated connection
,
!207
WIP: Client Restructure
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
connections/authenticated/authenticated.go
+2
-3
2 additions, 3 deletions
connections/authenticated/authenticated.go
connections/authenticated/client.go
+22
-8
22 additions, 8 deletions
connections/authenticated/client.go
with
24 additions
and
11 deletions
connections/authenticated/authenticated.go
+
2
−
3
View file @
395fa282
...
@@ -92,11 +92,11 @@ func ConnectWithAuthentication(recipient contact.Contact,
...
@@ -92,11 +92,11 @@ func ConnectWithAuthentication(recipient contact.Contact,
return
nil
,
err
return
nil
,
err
}
}
// Block waiting for auth to confirm
// Block waiting for auth to confirm
it timeouts
jww
.
DEBUG
.
Printf
(
"Connection waiting for authenticated "
+
jww
.
DEBUG
.
Printf
(
"Connection waiting for authenticated "
+
"connection with %s to be established..."
,
recipient
.
ID
.
String
())
"connection with %s to be established..."
,
recipient
.
ID
.
String
())
timeout
:=
time
.
NewTimer
(
p
.
Timeout
)
timeout
:=
time
.
NewTimer
(
p
.
Timeout
)
defer
timeout
.
Stop
()
select
{
select
{
case
newConnection
:=
<-
authConnChan
:
case
newConnection
:=
<-
authConnChan
:
if
newConnection
==
nil
{
if
newConnection
==
nil
{
...
@@ -104,7 +104,6 @@ func ConnectWithAuthentication(recipient contact.Contact,
...
@@ -104,7 +104,6 @@ func ConnectWithAuthentication(recipient contact.Contact,
"Unable to complete authenticated connection with partner %s"
,
"Unable to complete authenticated connection with partner %s"
,
recipient
.
ID
.
String
())
recipient
.
ID
.
String
())
}
}
return
newConnection
,
nil
return
newConnection
,
nil
case
<-
timeout
.
C
:
case
<-
timeout
.
C
:
return
nil
,
errors
.
Errorf
(
"Authenticated connection with "
+
return
nil
,
errors
.
Errorf
(
"Authenticated connection with "
+
...
...
This diff is collapsed.
Click to expand it.
connections/authenticated/client.go
+
22
−
8
View file @
395fa282
...
@@ -27,6 +27,15 @@ type client interface {
...
@@ -27,6 +27,15 @@ type client interface {
// clientHandler provides an implementation of the client interface.
// clientHandler provides an implementation of the client interface.
type
clientHandler
struct
{
type
clientHandler
struct
{
// This will handle the client's auth.Callbacks
clientAuth
// This will handle the confirmation message sent by the serverHandler.
clientListener
}
// clientListener provides an implementation for client's listener.
// This will handle the confirmation message sent by the serverHandler.
type
clientListener
struct
{
// connectionCallback allows an authenticated.Connection
// connectionCallback allows an authenticated.Connection
// to be passed back upon establishment.
// to be passed back upon establishment.
connectionCallback
ConnectionCallback
connectionCallback
ConnectionCallback
...
@@ -36,35 +45,40 @@ type clientHandler struct {
...
@@ -36,35 +45,40 @@ type clientHandler struct {
connectionParams
connect
.
Params
connectionParams
connect
.
Params
}
}
// clientAuth provides an implementation for client's auth.Callbacks.
type
clientAuth
struct
{}
// getClient returns a client interface to be used to handle
// getClient returns a client interface to be used to handle
// auth.Callbacks and receive.Listener operations.
// auth.Callbacks and receive.Listener operations.
func
getClient
(
cb
ConnectionCallback
,
func
getClient
(
cb
ConnectionCallback
,
e2e
clientE2e
.
Handler
,
p
connect
.
Params
)
client
{
e2e
clientE2e
.
Handler
,
p
connect
.
Params
)
client
{
return
clientHandler
{
return
clientHandler
{
clientListener
:
clientListener
{
connectionCallback
:
cb
,
connectionCallback
:
cb
,
connectionE2e
:
e2e
,
connectionE2e
:
e2e
,
connectionParams
:
p
,
connectionParams
:
p
,
},
}
}
}
}
// Request will be called when an auth Request message is processed.
// Request will be called when an auth Request message is processed.
func
(
a
client
Handler
)
Request
(
requestor
contact
.
Contact
,
func
(
a
client
Auth
)
Request
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
}
}
// Confirm will be called when an auth Confirm message is processed.
// Confirm will be called when an auth Confirm message is processed.
func
(
a
client
Handler
)
Confirm
(
requestor
contact
.
Contact
,
func
(
a
client
Auth
)
Confirm
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
}
}
// Reset will be called when an auth Reset operation occurs.
// Reset will be called when an auth Reset operation occurs.
func
(
a
client
Handler
)
Reset
(
requestor
contact
.
Contact
,
func
(
a
client
Auth
)
Reset
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
}
}
// Hear handles the reception of an IdentityAuthentication by the
// Hear handles the reception of an IdentityAuthentication by the
// server.
// server.
func
(
a
client
Handl
er
)
Hear
(
item
receive
.
Message
)
{
func
(
a
client
Listen
er
)
Hear
(
item
receive
.
Message
)
{
// Process the message data into a protobuf
// Process the message data into a protobuf
iar
:=
&
IdentityAuthentication
{}
iar
:=
&
IdentityAuthentication
{}
err
:=
proto
.
Unmarshal
(
item
.
Payload
,
iar
)
err
:=
proto
.
Unmarshal
(
item
.
Payload
,
iar
)
...
@@ -122,6 +136,6 @@ func (a clientHandler) Hear(item receive.Message) {
...
@@ -122,6 +136,6 @@ func (a clientHandler) Hear(item receive.Message) {
a
.
connectionParams
))
a
.
connectionParams
))
}
}
func
(
a
client
Handl
er
)
Name
()
string
{
func
(
a
client
Listen
er
)
Name
()
string
{
return
clientListenerName
return
clientListenerName
}
}
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