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
3c35b9d6
Commit
3c35b9d6
authored
3 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
add default cases
parent
3d7e775c
No related branches found
No related tags found
4 merge requests
!510
Release
,
!207
WIP: Client Restructure
,
!206
Built the connection interface which wraps e2e and auth objects and manages a...
,
!203
Symmetric broadcast
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
connect/connect.go
+17
-12
17 additions, 12 deletions
connect/connect.go
with
17 additions
and
12 deletions
connect/connect.go
+
17
−
12
View file @
3c35b9d6
...
@@ -89,7 +89,7 @@ func Connect(recipient contact.Contact, myId *id.ID, rng *fastRNG.StreamGenerato
...
@@ -89,7 +89,7 @@ func Connect(recipient contact.Contact, myId *id.ID, rng *fastRNG.StreamGenerato
}
}
// Build callback for E2E negotiation
// Build callback for E2E negotiation
callback
:=
G
et
Connection
Callback
()
callback
:=
g
et
Auth
Callback
()
// Build auth object for E2E negotiation
// Build auth object for E2E negotiation
authState
,
err
:=
auth
.
NewState
(
kv
,
net
,
e2eHandler
,
authState
,
err
:=
auth
.
NewState
(
kv
,
net
,
e2eHandler
,
...
@@ -140,7 +140,7 @@ func WaitForConnections(connectionListener chan Connection,
...
@@ -140,7 +140,7 @@ func WaitForConnections(connectionListener chan Connection,
}
}
// Build callback for E2E negotiation
// Build callback for E2E negotiation
callback
:=
G
et
Connection
Callback
()
callback
:=
g
et
Auth
Callback
()
// Build auth object for E2E negotiation
// Build auth object for E2E negotiation
_
,
err
=
auth
.
NewState
(
kv
,
net
,
e2eHandler
,
_
,
err
=
auth
.
NewState
(
kv
,
net
,
e2eHandler
,
...
@@ -165,11 +165,16 @@ func WaitForConnections(connectionListener chan Connection,
...
@@ -165,11 +165,16 @@ func WaitForConnections(connectionListener chan Connection,
continue
continue
}
}
connectionListener
<-
&
handler
{
// Send the new Connection object to the connectionListener
select
{
case
connectionListener
<-
&
handler
{
partner
:
newPartner
,
partner
:
newPartner
,
params
:
p
,
params
:
p
,
net
:
net
,
net
:
net
,
e2e
:
e2eHandler
,
e2e
:
e2eHandler
,
}
:
default
:
jww
.
ERROR
.
Printf
(
"Failed to establish new connection due to channel full."
)
}
}
}
}
}
}
...
@@ -214,31 +219,31 @@ func (h *handler) Unregister(listenerID receive.ListenerID) {
...
@@ -214,31 +219,31 @@ func (h *handler) Unregister(listenerID receive.ListenerID) {
h
.
e2e
.
Unregister
(
listenerID
)
h
.
e2e
.
Unregister
(
listenerID
)
}
}
//
Connection
Callback provides callback functionality for interfacing between auth.State and Connection
//
auth
Callback provides callback functionality for interfacing between auth.State and Connection
// This is used both for blocking creation of a Connection object until the auth Request is confirmed
// This is used both for blocking creation of a Connection object until the auth Request is confirmed
// and for dynamically building new Connection objects when an auth Request is received.
// and for dynamically building new Connection objects when an auth Request is received.
type
Connection
Callback
struct
{
type
auth
Callback
struct
{
// Used for signaling confirmation of E2E partnership
// Used for signaling confirmation of E2E partnership
confirmPartner
chan
*
id
.
ID
confirmPartner
chan
*
id
.
ID
}
}
//
G
et
Connection
Callback returns a callback interface to be passed into the creation of an auth.State object.
//
g
et
Auth
Callback returns a callback interface to be passed into the creation of an auth.State object.
func
G
et
Connection
Callback
()
Connection
Callback
{
func
g
et
Auth
Callback
()
auth
Callback
{
return
Connection
Callback
{
return
auth
Callback
{
confirmPartner
:
make
(
chan
*
id
.
ID
,
1
),
confirmPartner
:
make
(
chan
*
id
.
ID
,
1
0
),
}
}
}
}
// Confirm will be called when an auth Confirm message is processed
// Confirm will be called when an auth Confirm message is processed
func
(
c
Connection
Callback
)
Confirm
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
func
(
c
auth
Callback
)
Confirm
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
// Signal to a listening thread that the partnership is confirmed
// Signal to a listening thread that the partnership is confirmed
c
.
confirmPartner
<-
requestor
.
ID
c
.
confirmPartner
<-
requestor
.
ID
}
}
// Request will be called when an auth Request message is processed
// Request will be called when an auth Request message is processed
func
(
c
Connection
Callback
)
Request
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
func
(
c
auth
Callback
)
Request
(
requestor
contact
.
Contact
,
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
(
c
Connection
Callback
)
Reset
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
func
(
c
auth
Callback
)
Reset
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
}
}
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