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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
7dc7231c
Commit
7dc7231c
authored
Jul 31, 2019
by
Rick Carback
Browse files
Options
Downloads
Patches
Plain Diff
Clean up timeout processing
parent
f256a1cc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/root.go
+15
-10
15 additions, 10 deletions
cmd/root.go
io/messaging.go
+4
-4
4 additions, 4 deletions
io/messaging.go
with
19 additions
and
14 deletions
cmd/root.go
+
15
−
10
View file @
7dc7231c
...
...
@@ -9,6 +9,7 @@ package cmd
import
(
"encoding/base64"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/spf13/cobra"
jww
"github.com/spf13/jwalterweatherman"
...
...
@@ -87,13 +88,13 @@ func sessionInitialization() (*id.User, *api.Client) {
}
// Verify the signature
globals
.
Log
.
INFO
.
Println
(
"Verifying NDF..."
)
globals
.
Log
.
DEBUG
.
Println
(
"Verifying NDF..."
)
ndfJSON
:=
api
.
VerifyNDF
(
string
(
ndfBytes
),
ndfPubKey
)
globals
.
Log
.
INFO
.
Printf
(
"NDF Verified: %v"
,
ndfJSON
)
globals
.
Log
.
DEBUG
.
Printf
(
"NDF Verified: %v"
,
ndfJSON
)
// Overwrite the network definition with any specified flags
overwriteNDF
(
ndfJSON
)
globals
.
Log
.
INFO
.
Printf
(
"Overwrote NDF Vars: %v"
,
ndfJSON
)
globals
.
Log
.
DEBUG
.
Printf
(
"Overwrote NDF Vars: %v"
,
ndfJSON
)
//If no session file is passed initialize with RAM Storage
if
sessionFile
==
""
{
...
...
@@ -283,7 +284,8 @@ func (l *TextListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
}
else
{
senderNick
=
sender
.
Nick
}
globals
.
Log
.
INFO
.
Printf
(
"Message from %v, %v Received: %s
\n
"
,
large
.
NewIntFromBytes
(
message
.
Sender
[
:
])
.
Text
(
10
),
fmt
.
Printf
(
"Message from %v, %v Received: %s
\n
"
,
large
.
NewIntFromBytes
(
message
.
Sender
[
:
])
.
Text
(
10
),
senderNick
,
result
.
Message
)
atomic
.
AddInt64
(
&
l
.
MessagesReceived
,
1
)
...
...
@@ -315,7 +317,7 @@ func (l *ChannelListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
senderNick
=
sender
.
Nick
}
globals
.
Log
.
INFO
.
Printf
(
"Message from channel %v, %v: "
,
fmt
.
Printf
(
"Message from channel %v, %v: "
,
new
(
big
.
Int
)
.
SetBytes
(
message
.
Sender
[
:
])
.
Text
(
10
),
senderNick
)
typedBody
,
_
:=
parse
.
Parse
(
result
.
Message
)
speakerId
:=
id
.
NewUserFromBytes
(
result
.
SpeakerID
)
...
...
@@ -392,7 +394,7 @@ var rootCmd = &cobra.Command{
// Handle sending to any other destination
wireOut
:=
api
.
FormatTextMessage
(
message
)
globals
.
Log
.
INFO
.
Printf
(
"Sending Message to %d, %v: %s
\n
"
,
destinationUserId
,
fmt
.
Printf
(
"Sending Message to %d, %v: %s
\n
"
,
destinationUserId
,
recipientNick
,
message
)
// Send the message
...
...
@@ -445,14 +447,17 @@ var rootCmd = &cobra.Command{
}
}
else
{
// Wait up to 45 seconds to receive a message
for
timeout
:=
time
.
After
(
45
*
time
.
Second
);
;
{
for
end
,
timeout
:=
true
,
time
.
After
(
45
*
time
.
Second
);
end
;
{
if
text
.
MessagesReceived
>
0
{
break
end
=
true
}
select
{
case
<-
timeout
:
break
fmt
.
Println
(
"Timing out client "
+
"as no messages have"
+
" been received"
)
end
=
true
default
:
}
}
...
...
@@ -583,7 +588,7 @@ func initConfig() {}
// initLog initializes logging thresholds and the log path.
func
initLog
()
{
globals
.
Log
=
jww
.
NewNotepad
(
jww
.
LevelError
,
jww
.
Level
Warn
,
os
.
Stdout
,
globals
.
Log
=
jww
.
NewNotepad
(
jww
.
LevelError
,
jww
.
Level
Info
,
os
.
Stdout
,
ioutil
.
Discard
,
"CLIENT"
,
log
.
Ldate
|
log
.
Ltime
)
// If verbose flag set then log more info for debugging
if
verbose
||
viper
.
GetBool
(
"verbose"
)
{
...
...
This diff is collapsed.
Click to expand it.
io/messaging.go
+
4
−
4
View file @
7dc7231c
...
...
@@ -208,7 +208,7 @@ func handleE2ESending(session user.Session,
// FIXME: This is a hack to prevent a crash, this function should be
// able to block until this condition is true.
for
timeout
:=
time
.
After
(
60
*
time
.
Second
);
;
{
for
end
,
timeout
:=
false
,
time
.
After
(
60
*
time
.
Second
);
end
;
{
if
rekey
{
// Get send Rekey
key
,
action
=
km
.
PopRekey
()
...
...
@@ -217,12 +217,12 @@ func handleE2ESending(session user.Session,
key
,
action
=
km
.
PopKey
()
}
if
key
!=
nil
{
break
end
=
true
}
select
{
case
<-
timeout
:
break
end
=
true
default
:
}
}
...
...
@@ -288,7 +288,7 @@ func (m *Messaging) MessageReceiver(session user.Session, delay time.Duration) {
return
default
:
time
.
Sleep
(
delay
)
globals
.
Log
.
INFO
.
Printf
(
"Attempting to receive message from gateway"
)
globals
.
Log
.
DEBUG
.
Printf
(
"Attempting to receive message from gateway"
)
decryptedMessages
:=
m
.
receiveMessagesFromGateway
(
session
,
&
pollingMessage
)
if
decryptedMessages
!=
nil
{
for
i
:=
range
decryptedMessages
{
...
...
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