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
8897b74d
Commit
8897b74d
authored
2 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Fix formatting and error prints inside prepareSendE2E
parent
0f0d9270
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!510
Release
,
!353
Figure out why bindings is not passing parameters correctly
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
e2e/sendE2E.go
+36
-24
36 additions, 24 deletions
e2e/sendE2E.go
with
36 additions
and
24 deletions
e2e/sendE2E.go
+
36
−
24
View file @
8897b74d
...
...
@@ -63,22 +63,25 @@ func (m *manager) prepareSendE2E(mt catalog.MessageType, recipient *id.ID,
partitions
,
internalMsgId
,
err
:=
m
.
partitioner
.
Partition
(
recipient
,
mt
,
ts
,
payload
)
if
err
!=
nil
{
return
nil
,
errors
.
WithMessage
(
err
,
"failed to send unsafe message"
)
return
nil
,
errors
.
WithMessage
(
err
,
"failed to send unsafe message"
)
}
jww
.
INFO
.
Printf
(
"E2E sending %d messages to %s"
,
len
(
partitions
),
recipient
)
jww
.
INFO
.
Printf
(
"E2E sending %d messages to %s"
,
len
(
partitions
),
recipient
)
// When sending E2E messages, we first partition into cMix
packets and then
// send each partition over cMix
// When sending E2E messages, we first partition into cMix
//
packets and then
send each partition over cMix
roundIds
:=
make
([]
id
.
Round
,
len
(
partitions
))
errCh
:=
make
(
chan
error
,
len
(
partitions
))
// The Key manager for the partner (recipient) ensures single
use of each
// key negotiated for the ratchet
// The Key manager for the partner (recipient) ensures single
//
use of each
key negotiated for the ratchet
partner
,
err
:=
m
.
Ratchet
.
GetPartner
(
recipient
)
if
err
!=
nil
{
return
nil
,
errors
.
WithMessagef
(
err
,
"cannot send E2E message no relationship found with %s"
,
recipient
)
"cannot send E2E message no relationship found with %s"
,
recipient
)
}
msgID
:=
e2e
.
NewMessageID
(
...
...
@@ -89,15 +92,17 @@ func (m *manager) prepareSendE2E(mt catalog.MessageType, recipient *id.ID,
for
i
,
p
:=
range
partitions
{
if
mt
!=
catalog
.
KeyExchangeTrigger
{
// Check if any rekeys need to happen and trigger them
rekeySendFunc
:=
func
(
mt
catalog
.
MessageType
,
recipient
*
id
.
ID
,
rekeySendFunc
:=
func
(
mt
catalog
.
MessageType
,
recipient
*
id
.
ID
,
payload
[]
byte
,
cmixParams
cmix
.
CMIXParams
)
(
[]
id
.
Round
,
e2e
.
MessageID
,
time
.
Time
,
error
)
{
par
:=
params
par
.
CMIXParams
=
cmixParams
return
m
.
SendE2E
(
mt
,
recipient
,
payload
,
par
)
}
rekey
.
CheckKeyExchanges
(
m
.
net
.
GetInstance
(),
m
.
grp
,
rekeySendFunc
,
m
.
events
,
partner
,
m
.
rekeyParams
,
1
*
time
.
Minute
)
rekey
.
CheckKeyExchanges
(
m
.
net
.
GetInstance
(),
m
.
grp
,
rekeySendFunc
,
m
.
events
,
partner
,
m
.
rekeyParams
,
1
*
time
.
Minute
)
}
var
keyGetter
func
()
(
session
.
Cypher
,
error
)
...
...
@@ -107,23 +112,25 @@ func (m *manager) prepareSendE2E(mt catalog.MessageType, recipient *id.ID,
keyGetter
=
partner
.
PopSendCypher
}
// FIXME: remove this wait, it is weird. Why is it here? we cant remember.
// FIXME: remove this wait, it is weird. Why is it
// here? we cant remember.
key
,
err
:=
waitForKey
(
keyGetter
,
params
.
KeyGetRetryCount
,
params
.
KeyGeRetryDelay
,
keyGetter
,
params
.
KeyGetRetryCount
,
params
.
KeyGeRetryDelay
,
params
.
Stop
,
recipient
,
format
.
DigestContents
(
p
),
i
)
if
err
!=
nil
{
return
nil
,
errors
.
WithMessagef
(
err
,
"Failed to get key for end-to-end encryption"
)
}
// This does not encrypt for cMix but instead
end-to-end encrypts the
// cMix message
// This does not encrypt for cMix but instead
//
end-to-end encrypts the
cMix message
contentsEnc
,
mac
:=
key
.
Encrypt
(
p
)
jww
.
INFO
.
Printf
(
"
E2E sending %d/%d to %s with key fp: %s,
msgID: %s (msgDigest %s)"
,
i
+
i
,
len
(
partitions
),
recipient
,
key
.
Fingerprint
(),
msgID
,
format
.
DigestContents
(
p
))
jww
.
INFO
.
Printf
(
"E2E sending %d/%d to %s with key fp: %s, "
+
"msgID: %s (msgDigest %s)"
,
i
+
i
,
len
(
partitions
),
recipient
,
key
.
Fingerprint
(),
msgID
,
format
.
DigestContents
(
p
))
var
s
message
.
Service
if
i
==
len
(
partitions
)
-
1
{
...
...
@@ -132,16 +139,20 @@ func (m *manager) prepareSendE2E(mt catalog.MessageType, recipient *id.ID,
s
=
partner
.
MakeService
(
params
.
ServiceTag
)
}
// We send each partition in its own thread here; some may send in round
// X, others in X+1 or X+2, and so on
// We send each partition in its own thread here; some
// may send in round X, others in X+1 or X+2, and so
// on
localI
:=
i
thisSendFunc
:=
func
()
{
wg
.
Add
(
1
)
go
func
(
i
int
)
{
var
err
error
roundIds
[
i
],
_
,
err
=
m
.
net
.
Send
(
recipient
,
key
.
Fingerprint
(),
s
,
contentsEnc
,
mac
,
params
.
CMIXParams
)
key
.
Fingerprint
(),
s
,
contentsEnc
,
mac
,
params
.
CMIXParams
)
if
err
!=
nil
{
jww
.
DEBUG
.
Printf
(
"[E2E] cMix error on "
+
"Send: %+v"
,
err
)
errCh
<-
err
}
wg
.
Done
()
...
...
@@ -166,11 +177,12 @@ func (m *manager) prepareSendE2E(mt catalog.MessageType, recipient *id.ID,
numFail
,
len
(
partitions
),
errRtn
)
}
else
{
jww
.
INFO
.
Printf
(
"Successfully E2E sent %d/%d to %s"
,
len
(
partitions
)
-
numFail
,
len
(
partitions
),
recipient
)
len
(
partitions
)
-
numFail
,
len
(
partitions
),
recipient
)
}
jww
.
INFO
.
Printf
(
"Successful E2E Send of %d messages to %s
with msgID %s"
,
len
(
partitions
),
recipient
,
msgID
)
jww
.
INFO
.
Printf
(
"Successful E2E Send of %d messages to %s
"
+
"with msgID %s"
,
len
(
partitions
),
recipient
,
msgID
)
return
roundIds
,
msgID
,
ts
,
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