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
1d25fdae
Commit
1d25fdae
authored
3 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Add timeout to connect/ package
parent
b9d73b83
No related branches found
No related tags found
3 merge requests
!510
Release
,
!216
Xx 3895/authenticated connection
,
!207
WIP: Client Restructure
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
connections/connect/connect.go
+25
-13
25 additions, 13 deletions
connections/connect/connect.go
with
25 additions
and
13 deletions
connections/connect/connect.go
+
25
−
13
View file @
1d25fdae
...
@@ -30,6 +30,12 @@ import (
...
@@ -30,6 +30,12 @@ import (
"time"
"time"
)
)
const
(
// connectionTimeout is the time.Duration for a connection
// to be established before the requester times out.
connectionTimeout
=
15
*
time
.
Second
)
// Connection is a wrapper for the E2E and auth packages.
// Connection is a wrapper for the E2E and auth packages.
// It can be used to automatically establish an E2E partnership
// It can be used to automatically establish an E2E partnership
// with a partner.Manager, or be built from an existing E2E partnership.
// with a partner.Manager, or be built from an existing E2E partnership.
...
@@ -73,6 +79,7 @@ func GetDefaultParams() Params {
...
@@ -73,6 +79,7 @@ func GetDefaultParams() Params {
Auth
:
auth
.
GetDefaultParams
(),
Auth
:
auth
.
GetDefaultParams
(),
Rekey
:
rekey
.
GetDefaultParams
(),
Rekey
:
rekey
.
GetDefaultParams
(),
Event
:
event
.
NewEventManager
(),
Event
:
event
.
NewEventManager
(),
Timeout
:
connectionTimeout
,
}
}
}
}
...
@@ -120,8 +127,10 @@ func Connect(recipient contact.Contact, myId *id.ID, privKey *cyclic.Int,
...
@@ -120,8 +127,10 @@ func Connect(recipient contact.Contact, myId *id.ID, privKey *cyclic.Int,
// Block waiting for auth to confirm
// Block waiting for auth to confirm
jww
.
DEBUG
.
Printf
(
"Connection waiting for auth request "
+
jww
.
DEBUG
.
Printf
(
"Connection waiting for auth request "
+
"for %s to be confirmed..."
,
recipient
.
ID
.
String
())
"for %s to be confirmed..."
,
recipient
.
ID
.
String
())
newConnection
:=
<-
signalChannel
timeout
:=
time
.
NewTimer
(
p
.
Timeout
)
defer
timeout
.
Stop
()
select
{
case
newConnection
:=
<-
signalChannel
:
// Verify the Connection is complete
// Verify the Connection is complete
if
newConnection
==
nil
{
if
newConnection
==
nil
{
return
nil
,
errors
.
Errorf
(
"Unable to complete connection "
+
return
nil
,
errors
.
Errorf
(
"Unable to complete connection "
+
...
@@ -129,8 +138,11 @@ func Connect(recipient contact.Contact, myId *id.ID, privKey *cyclic.Int,
...
@@ -129,8 +138,11 @@ func Connect(recipient contact.Contact, myId *id.ID, privKey *cyclic.Int,
}
}
jww
.
DEBUG
.
Printf
(
"Connection auth request for %s confirmed"
,
jww
.
DEBUG
.
Printf
(
"Connection auth request for %s confirmed"
,
recipient
.
ID
.
String
())
recipient
.
ID
.
String
())
return
newConnection
,
nil
return
newConnection
,
nil
case
<-
timeout
.
C
:
return
nil
,
errors
.
Errorf
(
"Connection request with "
+
"partner %s timed out"
,
recipient
.
ID
.
String
())
}
}
}
// RegisterConnectionCallback assembles a Connection object on the reception-side
// RegisterConnectionCallback assembles a Connection object on the reception-side
...
...
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