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
e7b87424
Commit
e7b87424
authored
3 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Better documentation/clean duplicate code
parent
f30748a7
No related branches found
No related tags found
2 merge requests
!510
Release
,
!235
Verify sends for auth messages
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/root.go
+17
-30
17 additions, 30 deletions
cmd/root.go
cmd/utils.go
+10
-0
10 additions, 0 deletions
cmd/utils.go
with
27 additions
and
30 deletions
cmd/root.go
+
17
−
30
View file @
e7b87424
...
...
@@ -265,27 +265,17 @@ var rootCmd = &cobra.Command{
paramsE2E
:=
e2e
.
GetDefaultParams
()
roundTimeout
:=
paramsE2E
.
CMIXParams
.
SendTimeout
if
viper
.
GetBool
(
"accept-channel"
)
{
// Verify that the confirmation message makes it to the
// original sender
if
viper
.
GetBool
(
"verify-sends"
)
{
done
:=
make
(
chan
struct
{},
1
)
retryChan
:=
make
(
chan
struct
{},
1
)
if
viper
.
GetBool
(
"verify-sends"
)
{
for
{
rid
:=
acceptChannel
(
client
,
recipientID
)
// Verify message sends were successful
// Construct the callback function which
// verifies successful message send or retries
f
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
cmix
.
RoundResult
)
{
if
!
allRoundsSucceeded
{
retryChan
<-
struct
{}{}
}
else
{
done
<-
struct
{}{}
}
}
// Monitor rounds for results
err
=
client
.
GetCmix
()
.
GetRoundResults
(
roundTimeout
,
f
,
rid
)
err
=
client
.
GetCmix
()
.
GetRoundResults
(
roundTimeout
,
makeVerifySendsCallback
(
retryChan
,
done
),
rid
)
if
err
!=
nil
{
jww
.
DEBUG
.
Printf
(
"Could not verify "
+
"confirmation message for relationship with %s were sent "
+
...
...
@@ -309,6 +299,7 @@ var rootCmd = &cobra.Command{
break
}
}
else
{
// Accept channel, agnostic of round result
acceptChannel
(
client
,
recipientID
)
}
...
...
@@ -802,22 +793,15 @@ func addAuthenticatedChannel(client *messenger.Client, recipientID *id.ID,
me
:=
client
.
GetUser
()
.
GetContact
()
jww
.
INFO
.
Printf
(
"Requesting auth channel from: %s"
,
recipientID
)
retryChan
:=
make
(
chan
struct
{},
1
)
done
:=
make
(
chan
struct
{},
1
)
paramsE2E
:=
e2e
.
GetDefaultParams
()
roundTimeout
:=
paramsE2E
.
CMIXParams
.
SendTimeout
// Verify that the auth request makes it to the recipient
// by monitoring the round result
if
viper
.
GetBool
(
"verify-sends"
)
{
retryChan
:=
make
(
chan
struct
{},
1
)
done
:=
make
(
chan
struct
{},
1
)
for
{
// Construct the callback function which
// verifies successful message send or retries
f
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
cmix
.
RoundResult
)
{
if
!
allRoundsSucceeded
{
retryChan
<-
struct
{}{}
}
else
{
done
<-
struct
{}{}
}
}
rid
,
err
:=
client
.
GetAuth
()
.
Request
(
recipientContact
,
me
.
Facts
)
if
err
!=
nil
{
...
...
@@ -825,7 +809,9 @@ func addAuthenticatedChannel(client *messenger.Client, recipientID *id.ID,
}
// Monitor rounds for results
err
=
client
.
GetCmix
()
.
GetRoundResults
(
roundTimeout
,
f
,
rid
)
err
=
client
.
GetCmix
()
.
GetRoundResults
(
roundTimeout
,
makeVerifySendsCallback
(
retryChan
,
done
),
rid
)
if
err
!=
nil
{
jww
.
DEBUG
.
Printf
(
"Could not verify auth request was sent "
+
"successfully, resending..."
)
...
...
@@ -835,7 +821,7 @@ func addAuthenticatedChannel(client *messenger.Client, recipientID *id.ID,
select
{
case
<-
retryChan
:
// On a retry, go to the top of the loop
jww
.
DEBUG
.
Printf
(
"Auth
R
equest was not sent "
+
jww
.
DEBUG
.
Printf
(
"Auth
r
equest was not sent "
+
"successfully, resending..."
)
continue
case
<-
done
:
...
...
@@ -847,6 +833,7 @@ func addAuthenticatedChannel(client *messenger.Client, recipientID *id.ID,
break
}
}
else
{
// Just call Request, agnostic of round result
_
,
err
:=
client
.
GetAuth
()
.
Request
(
recipientContact
,
me
.
Facts
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
cmd/utils.go
+
10
−
0
View file @
e7b87424
...
...
@@ -108,3 +108,13 @@ func readContact() contact.Contact {
jww
.
INFO
.
Printf
(
"Contact ID: %s"
,
c
.
ID
)
return
c
}
func
makeVerifySendsCallback
(
retryChan
,
done
chan
struct
{})
cmix
.
RoundEventCallback
{
return
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
cmix
.
RoundResult
)
{
if
!
allRoundsSucceeded
{
retryChan
<-
struct
{}{}
}
else
{
done
<-
struct
{}{}
}
}
}
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