Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
client
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
katzenpost
client
Commits
fb47abdd
Commit
fb47abdd
authored
Sep 20, 2019
by
David Stainton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Async send instead of blocking
parent
361636bf
Pipeline
#940
passed with stage
in 7 minutes and 23 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
client_test.go
client_test.go
+8
-4
session/message.go
session/message.go
+1
-1
session/send.go
session/send.go
+4
-4
No files found.
client_test.go
View file @
fb47abdd
...
...
@@ -68,9 +68,11 @@ func TestClientConnect(t *testing.T) {
// send a message
t
.
Logf
(
"desc.Provider: %s"
,
desc
.
Provider
)
_
,
err
=
s
.
SendUnreliableMessage
(
desc
.
Name
,
desc
.
Provider
,
[]
byte
(
"hello!"
))
t
.
Logf
(
"Sent unreliable message to loop service"
)
mesgID
,
err
:=
s
.
SendUnreliableMessage
(
desc
.
Name
,
desc
.
Provider
,
[]
byte
(
"hello!"
))
require
.
NoError
(
err
)
_
,
err
=
s
.
WaitForReply
(
mesgID
)
require
.
NoError
(
err
)
t
.
Logf
(
"Sent unreliable message to loop service"
)
c
.
Shutdown
()
t
.
Logf
(
"Shutdown requested"
)
...
...
@@ -160,9 +162,11 @@ func TestDecoyClient(t *testing.T) {
wg
.
Add
(
1
)
go
func
()
{
t
.
Logf
(
"SendUnreliableMessage()"
)
_
,
err
:=
s
.
SendUnreliableMessage
(
desc
.
Name
,
desc
.
Provider
,
[]
byte
(
"hello!"
))
wg
.
Done
()
mesgID
,
err
:=
s
.
SendUnreliableMessage
(
desc
.
Name
,
desc
.
Provider
,
[]
byte
(
"hello!"
))
require
.
NoError
(
err
)
_
,
err
=
s
.
WaitForReply
(
mesgID
)
require
.
NoError
(
err
)
wg
.
Done
()
}()
}
wg
.
Wait
()
...
...
session/message.go
View file @
fb47abdd
...
...
@@ -30,7 +30,7 @@ type MessageID *[cConstants.MessageIDLength]byte
// received SURB replies.
type
Message
struct
{
// ID is the message identifier
ID
*
[
cConstants
.
MessageIDLength
]
byte
ID
MessageID
// Recipient is the message recipient
Recipient
string
...
...
session/send.go
View file @
fb47abdd
...
...
@@ -73,7 +73,7 @@ func (s *Session) waitForSent(id MessageID) error {
}
// WaitForReply blocks until a reply is received.
func
(
s
*
Session
)
w
aitForReply
(
id
MessageID
)
([]
byte
,
error
)
{
func
(
s
*
Session
)
W
aitForReply
(
id
MessageID
)
([]
byte
,
error
)
{
s
.
log
.
Debugf
(
"WaitForReply message ID: %x
\n
"
,
*
id
)
err
:=
s
.
waitForSent
(
id
)
if
err
!=
nil
{
...
...
@@ -259,8 +259,8 @@ func (s *Session) composeMessage(recipient, provider string, message []byte) (*M
return
&
msg
,
nil
}
// SendUnreliableMessage sends message without any automatic retransmissions.
func
(
s
*
Session
)
SendUnreliableMessage
(
recipient
,
provider
string
,
message
[]
byte
)
(
[]
byte
,
error
)
{
// SendUnreliableMessage
asynchronously
sends message without any automatic retransmissions.
func
(
s
*
Session
)
SendUnreliableMessage
(
recipient
,
provider
string
,
message
[]
byte
)
(
MessageID
,
error
)
{
msg
,
err
:=
s
.
composeMessage
(
recipient
,
provider
,
message
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -276,5 +276,5 @@ func (s *Session) SendUnreliableMessage(recipient, provider string, message []by
if
err
!=
nil
{
return
nil
,
err
}
return
s
.
waitForReply
(
msg
.
ID
)
return
msg
.
ID
,
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment