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
9ace7715
Commit
9ace7715
authored
2 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
fixed connection so servers properly handle requests and confirmations
parent
83a501e6
No related branches found
No related tags found
3 merge requests
!510
Release
,
!226
WIP: Api2.0
,
!207
WIP: Client Restructure
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
connect/connect.go
+38
-11
38 additions, 11 deletions
connect/connect.go
with
38 additions
and
11 deletions
connect/connect.go
+
38
−
11
View file @
9ace7715
...
@@ -143,7 +143,7 @@ func Connect(recipient contact.Contact, myId *id.ID, privKey *cyclic.Int,
...
@@ -143,7 +143,7 @@ func Connect(recipient contact.Contact, myId *id.ID, privKey *cyclic.Int,
cb
:=
func
(
connection
Connection
)
{
cb
:=
func
(
connection
Connection
)
{
signalChannel
<-
connection
signalChannel
<-
connection
}
}
callback
:=
getAuthCallback
(
cb
,
e2eHandler
,
p
)
callback
:=
getAuthCallback
(
cb
,
nil
,
e2eHandler
,
p
)
// 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
,
...
@@ -200,7 +200,7 @@ func StartServer(cb Callback, myId *id.ID, privKey *cyclic.Int,
...
@@ -200,7 +200,7 @@ func StartServer(cb Callback, myId *id.ID, privKey *cyclic.Int,
}
}
// Build callback for E2E negotiation
// Build callback for E2E negotiation
callback
:=
getAuthCallback
(
cb
,
e2eHandler
,
p
)
callback
:=
getAuthCallback
(
nil
,
cb
,
e2eHandler
,
p
)
// 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
,
...
@@ -265,7 +265,8 @@ func (h *handler) Unregister(listenerID receive.ListenerID) {
...
@@ -265,7 +265,8 @@ func (h *handler) Unregister(listenerID receive.ListenerID) {
// building new Connection objects when an auth Request is received.
// building new Connection objects when an auth Request is received.
type
authCallback
struct
{
type
authCallback
struct
{
// Used for signaling confirmation of E2E partnership
// Used for signaling confirmation of E2E partnership
connectionCallback
Callback
confrimCallback
Callback
requestCallback
Callback
// Used for building new Connection objects
// Used for building new Connection objects
connectionE2e
clientE2e
.
Handler
connectionE2e
clientE2e
.
Handler
...
@@ -275,12 +276,14 @@ type authCallback struct {
...
@@ -275,12 +276,14 @@ type authCallback struct {
// getAuthCallback returns a callback interface to be passed into the creation
// getAuthCallback returns a callback interface to be passed into the creation
// of an auth.State object.
// of an auth.State object.
func
getAuthCallback
(
cb
Callback
,
e2e
clientE2e
.
Handler
,
// it will accept requests only if a request callback is passed in
func
getAuthCallback
(
confirm
,
request
Callback
,
e2e
clientE2e
.
Handler
,
params
Params
)
*
authCallback
{
params
Params
)
*
authCallback
{
return
&
authCallback
{
return
&
authCallback
{
connectionCallback
:
cb
,
confrimCallback
:
confirm
,
connectionE2e
:
e2e
,
requestCallback
:
request
,
connectionParams
:
params
,
connectionE2e
:
e2e
,
connectionParams
:
params
,
}
}
}
}
...
@@ -296,25 +299,49 @@ func (a authCallback) Confirm(requestor contact.Contact,
...
@@ -296,25 +299,49 @@ func (a authCallback) Confirm(requestor contact.Contact,
jww
.
ERROR
.
Printf
(
"Unable to build connection with "
+
jww
.
ERROR
.
Printf
(
"Unable to build connection with "
+
"partner %s: %+v"
,
requestor
.
ID
,
err
)
"partner %s: %+v"
,
requestor
.
ID
,
err
)
// Send a nil connection to avoid hold-ups down the line
// Send a nil connection to avoid hold-ups down the line
a
.
connectionCallback
(
nil
)
if
a
.
confrimCallback
!=
nil
{
a
.
confrimCallback
(
nil
)
}
return
return
}
}
// Return the new Connection object
// Return the new Connection object
a
.
connectionCallback
(
BuildConnection
(
newPartner
,
a
.
connectionE2e
,
if
a
.
confrimCallback
!=
nil
{
a
.
connectionParams
))
a
.
confrimCallback
(
BuildConnection
(
newPartner
,
a
.
connectionE2e
,
a
.
connectionParams
))
}
}
}
// Request will be called when an auth Request message is processed.
// Request will be called when an auth Request message is processed.
func
(
a
authCallback
)
Request
(
requestor
contact
.
Contact
,
func
(
a
authCallback
)
Request
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
if
a
.
requestCallback
==
nil
{
jww
.
ERROR
.
Printf
(
"Recieved a request when requests are"
+
"not enable, will not accept"
)
}
_
,
err
:=
a
.
authState
.
Confirm
(
requestor
)
_
,
err
:=
a
.
authState
.
Confirm
(
requestor
)
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Unable to build connection with "
+
jww
.
ERROR
.
Printf
(
"Unable to build connection with "
+
"partner %s: %+v"
,
requestor
.
ID
,
err
)
"partner %s: %+v"
,
requestor
.
ID
,
err
)
// Send a nil connection to avoid hold-ups down the line
// Send a nil connection to avoid hold-ups down the line
a
.
connectionCallback
(
nil
)
a
.
requestCallback
(
nil
)
}
// After confirmation, get the new partner
newPartner
,
err
:=
a
.
connectionE2e
.
GetPartner
(
requestor
.
ID
)
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Unable to build connection with "
+
"partner %s: %+v"
,
requestor
.
ID
,
err
)
// Send a nil connection to avoid hold-ups down the line
a
.
requestCallback
(
nil
)
return
}
}
// Return the new Connection object
a
.
requestCallback
(
BuildConnection
(
newPartner
,
a
.
connectionE2e
,
a
.
connectionParams
))
}
}
// Reset will be called when an auth Reset operation occurs.
// Reset will be called when an auth Reset operation occurs.
...
...
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