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
8e6742de
Commit
8e6742de
authored
2 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
fix segfaults surrounding connect.Callbacks implementation of auth.Callbacks
parent
04e13e62
No related branches found
No related tags found
1 merge request
!510
Release
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
connect/authCallbacks.go
+19
-34
19 additions, 34 deletions
connect/authCallbacks.go
connect/connect.go
+2
-4
2 additions, 4 deletions
connect/connect.go
with
21 additions
and
38 deletions
connect/authCallbacks.go
+
19
−
34
View file @
8e6742de
...
...
@@ -17,13 +17,11 @@ import (
)
// clientAuthCallback 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 and for dynamically
// building new Connection objects when an auth Request is received.
// auth.State and Connection. This is used for building new Connection
// objects when an auth Confirm is received.
type
clientAuthCallback
struct
{
// Used for signaling confirmation of E2E partnership
confirmCallback
Callback
requestCallback
Callback
// Used for building new Connection objects
connectionE2e
clientE2e
.
Handler
...
...
@@ -31,14 +29,12 @@ type clientAuthCallback struct {
authState
auth
.
State
}
// getClientAuthCallback returns a callback interface to be passed into the creation
// of an auth.State object.
// it will accept requests only if a request callback is passed in
func
getClientAuthCallback
(
confirm
,
request
Callback
,
e2e
clientE2e
.
Handler
,
// getClientAuthCallback returns an auth.Callbacks interface to be passed into the creation
// of an auth.State object for connect clients.
func
getClientAuthCallback
(
confirm
Callback
,
e2e
clientE2e
.
Handler
,
auth
auth
.
State
,
params
xxdk
.
E2EParams
)
*
clientAuthCallback
{
return
&
clientAuthCallback
{
confirmCallback
:
confirm
,
requestCallback
:
request
,
connectionE2e
:
e2e
,
connectionParams
:
params
,
authState
:
auth
,
...
...
@@ -58,17 +54,13 @@ func (a clientAuthCallback) Confirm(requestor contact.Contact,
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
if
a
.
confirmCallback
!=
nil
{
a
.
confirmCallback
(
nil
)
}
a
.
confirmCallback
(
nil
)
return
}
// Return the new Connection object
if
a
.
confirmCallback
!=
nil
{
a
.
confirmCallback
(
BuildConnection
(
newPartner
,
a
.
connectionE2e
,
a
.
authState
,
a
.
connectionParams
))
}
a
.
confirmCallback
(
BuildConnection
(
newPartner
,
a
.
connectionE2e
,
a
.
authState
,
a
.
connectionParams
))
}
// Request will be called when an auth Request message is processed.
...
...
@@ -82,12 +74,10 @@ func (a clientAuthCallback) Reset(contact.Contact,
}
// serverAuthCallback 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 and for dynamically
// building new Connection objects when an auth Request is received.
// auth.State and Connection. This is used for building new Connection
//objects when an auth Request is received.
type
serverAuthCallback
struct
{
// Used for signaling confirmation of E2E partnership
confirmCallback
Callback
requestCallback
Callback
// Used to track stale connections
...
...
@@ -97,13 +87,11 @@ type serverAuthCallback struct {
connectionParams
xxdk
.
E2EParams
}
// getServerAuthCallback returns a callback interface to be passed into the creation
// of a xxdk.E2e object.
// it will accept requests only if a request callback is passed in
func
getServerAuthCallback
(
confirm
,
request
Callback
,
cl
*
ConnectionList
,
// getServerAuthCallback returns an auth.Callbacks interface to be passed into the creation
// of a xxdk.E2e object for connect servers.
func
getServerAuthCallback
(
request
Callback
,
cl
*
ConnectionList
,
params
xxdk
.
E2EParams
)
*
serverAuthCallback
{
return
&
serverAuthCallback
{
confirmCallback
:
confirm
,
requestCallback
:
request
,
cl
:
cl
,
connectionParams
:
params
,
...
...
@@ -118,25 +106,22 @@ func (a serverAuthCallback) Confirm(contact.Contact,
// Request will be called when an auth Request message is processed.
func
(
a
serverAuthCallback
)
Request
(
requestor
contact
.
Contact
,
_
receptionID
.
EphemeralIdentity
,
_
rounds
.
Round
,
user
*
xxdk
.
E2e
)
{
if
a
.
requestCallback
==
nil
{
jww
.
ERROR
.
Printf
(
"Received a request when requests are"
+
"not enable, will not accept"
)
}
jww
.
DEBUG
.
Printf
(
"Connection auth request for %s received"
,
requestor
.
ID
.
String
())
// Auto-confirm the auth request
_
,
err
:=
user
.
GetAuth
()
.
Confirm
(
requestor
)
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
}
// After confirmation, get the new partner
newPartner
,
err
:=
user
.
GetE2E
()
.
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
}
...
...
This diff is collapsed.
Click to expand it.
connect/connect.go
+
2
−
4
View file @
8e6742de
...
...
@@ -88,7 +88,7 @@ func Connect(recipient contact.Contact, user *xxdk.E2e,
cb
:=
func
(
connection
Connection
)
{
signalChannel
<-
connection
}
callback
:=
getClientAuthCallback
(
cb
,
nil
,
user
.
GetE2E
(),
callback
:=
getClientAuthCallback
(
cb
,
user
.
GetE2E
(),
user
.
GetAuth
(),
p
)
user
.
GetAuth
()
.
AddPartnerCallback
(
recipient
.
ID
,
callback
)
...
...
@@ -128,8 +128,6 @@ func Connect(recipient contact.Contact, user *xxdk.E2e,
//
// This calls xxdk.LoginEphemeral under the hood and the connection
// server must be the only listener on auth.
//
// The given Callback needs to handle receiving a nil Connection.
func
StartServer
(
identity
xxdk
.
ReceptionIdentity
,
connectionCallback
Callback
,
net
*
xxdk
.
Cmix
,
params
xxdk
.
E2EParams
,
clParams
ConnectionListParams
)
(
*
ConnectionServer
,
error
)
{
...
...
@@ -141,7 +139,7 @@ func StartServer(identity xxdk.ReceptionIdentity, connectionCallback Callback,
}
// Build callback for E2E negotiation
callback
:=
getServerAuthCallback
(
nil
,
connectionCallback
,
cl
,
params
)
callback
:=
getServerAuthCallback
(
connectionCallback
,
cl
,
params
)
e2eClient
,
err
:=
xxdk
.
LoginEphemeral
(
net
,
callback
,
identity
,
params
)
if
err
!=
nil
{
...
...
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