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
13d0605e
Commit
13d0605e
authored
3 years ago
by
Jonah Husson
Browse files
Options
Downloads
Plain Diff
Merge branch 'api2.0' of git.xx.network:elixxir/client into api2.0
parents
1439f131
1feaea26
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!510
Release
,
!226
WIP: Api2.0
,
!207
WIP: Client Restructure
Changes
1
Show 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 @
13d0605e
...
...
@@ -143,7 +143,7 @@ func Connect(recipient contact.Contact, myId *id.ID, privKey *cyclic.Int,
cb
:=
func
(
connection
Connection
)
{
signalChannel
<-
connection
}
callback
:=
getAuthCallback
(
cb
,
e2eHandler
,
p
)
callback
:=
getAuthCallback
(
cb
,
nil
,
e2eHandler
,
p
)
// Build auth object for E2E negotiation
authState
,
err
:=
auth
.
NewState
(
kv
,
net
,
e2eHandler
,
...
...
@@ -200,7 +200,7 @@ func StartServer(cb Callback, myId *id.ID, privKey *cyclic.Int,
}
// Build callback for E2E negotiation
callback
:=
getAuthCallback
(
cb
,
e2eHandler
,
p
)
callback
:=
getAuthCallback
(
nil
,
cb
,
e2eHandler
,
p
)
// Build auth object for E2E negotiation
authState
,
err
:=
auth
.
NewState
(
kv
,
net
,
e2eHandler
,
...
...
@@ -265,7 +265,8 @@ func (h *handler) Unregister(listenerID receive.ListenerID) {
// building new Connection objects when an auth Request is received.
type
authCallback
struct
{
// Used for signaling confirmation of E2E partnership
connectionCallback
Callback
confrimCallback
Callback
requestCallback
Callback
// Used for building new Connection objects
connectionE2e
clientE2e
.
Handler
...
...
@@ -275,10 +276,12 @@ type authCallback struct {
// getAuthCallback returns a callback interface to be passed into the creation
// 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
{
return
&
authCallback
{
connectionCallback
:
cb
,
confrimCallback
:
confirm
,
requestCallback
:
request
,
connectionE2e
:
e2e
,
connectionParams
:
params
,
}
...
...
@@ -296,25 +299,49 @@ func (a authCallback) 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
a
.
connectionCallback
(
nil
)
if
a
.
confrimCallback
!=
nil
{
a
.
confrimCallback
(
nil
)
}
return
}
// Return the new Connection object
a
.
connectionCallback
(
BuildConnection
(
newPartner
,
a
.
connectionE2e
,
if
a
.
confrimCallback
!=
nil
{
a
.
confrimCallback
(
BuildConnection
(
newPartner
,
a
.
connectionE2e
,
a
.
connectionParams
))
}
}
// Request will be called when an auth Request message is processed.
func
(
a
authCallback
)
Request
(
requestor
contact
.
Contact
,
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
)
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
.
connection
Callback
(
nil
)
a
.
request
Callback
(
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.
...
...
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