Skip to content
Snippets Groups Projects
Commit 0d35c5e1 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Merge branch 'hotfix/rekey_crash' into 'dispatch'

Clean up for integration tests

See merge request !168
parents 24c25de2 2079f8fd
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ package cmd ...@@ -9,6 +9,7 @@ package cmd
import ( import (
"encoding/base64" "encoding/base64"
"fmt"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/spf13/cobra" "github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
...@@ -87,13 +88,13 @@ func sessionInitialization() (*id.User, *api.Client) { ...@@ -87,13 +88,13 @@ func sessionInitialization() (*id.User, *api.Client) {
} }
// Verify the signature // Verify the signature
globals.Log.INFO.Println("Verifying NDF...") globals.Log.DEBUG.Println("Verifying NDF...")
ndfJSON := api.VerifyNDF(string(ndfBytes), ndfPubKey) 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 // Overwrite the network definition with any specified flags
overwriteNDF(ndfJSON) 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 no session file is passed initialize with RAM Storage
if sessionFile == "" { if sessionFile == "" {
...@@ -283,7 +284,8 @@ func (l *TextListener) Hear(item switchboard.Item, isHeardElsewhere bool) { ...@@ -283,7 +284,8 @@ func (l *TextListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
} else { } else {
senderNick = sender.Nick 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) senderNick, result.Message)
atomic.AddInt64(&l.MessagesReceived, 1) atomic.AddInt64(&l.MessagesReceived, 1)
...@@ -315,7 +317,7 @@ func (l *ChannelListener) Hear(item switchboard.Item, isHeardElsewhere bool) { ...@@ -315,7 +317,7 @@ func (l *ChannelListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
senderNick = sender.Nick 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) new(big.Int).SetBytes(message.Sender[:]).Text(10), senderNick)
typedBody, _ := parse.Parse(result.Message) typedBody, _ := parse.Parse(result.Message)
speakerId := id.NewUserFromBytes(result.SpeakerID) speakerId := id.NewUserFromBytes(result.SpeakerID)
...@@ -392,7 +394,7 @@ var rootCmd = &cobra.Command{ ...@@ -392,7 +394,7 @@ var rootCmd = &cobra.Command{
// Handle sending to any other destination // Handle sending to any other destination
wireOut := api.FormatTextMessage(message) 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) recipientNick, message)
// Send the message // Send the message
...@@ -444,15 +446,18 @@ var rootCmd = &cobra.Command{ ...@@ -444,15 +446,18 @@ var rootCmd = &cobra.Command{
timer = time.NewTimer(dummyPeriod) timer = time.NewTimer(dummyPeriod)
} }
} else { } else {
// Wait up to 45 seconds to receive a message // Wait up to 2 minutes to receive a message
for timeout := time.After(45 * time.Second); ; { for end, timeout := false, time.After(120*time.Second); !end; {
if text.MessagesReceived > 0 { if text.MessagesReceived > 0 {
break end = true
} }
select { select {
case <-timeout: case <-timeout:
break fmt.Println("Timing out client " +
"as no messages have" +
" been received")
end = true
default: default:
} }
} }
...@@ -583,7 +588,7 @@ func initConfig() {} ...@@ -583,7 +588,7 @@ func initConfig() {}
// initLog initializes logging thresholds and the log path. // initLog initializes logging thresholds and the log path.
func initLog() { func initLog() {
globals.Log = jww.NewNotepad(jww.LevelError, jww.LevelWarn, os.Stdout, globals.Log = jww.NewNotepad(jww.LevelError, jww.LevelInfo, os.Stdout,
ioutil.Discard, "CLIENT", log.Ldate|log.Ltime) ioutil.Discard, "CLIENT", log.Ldate|log.Ltime)
// If verbose flag set then log more info for debugging // If verbose flag set then log more info for debugging
if verbose || viper.GetBool("verbose") { if verbose || viper.GetBool("verbose") {
......
...@@ -208,7 +208,7 @@ func handleE2ESending(session user.Session, ...@@ -208,7 +208,7 @@ func handleE2ESending(session user.Session,
// FIXME: This is a hack to prevent a crash, this function should be // FIXME: This is a hack to prevent a crash, this function should be
// able to block until this condition is true. // 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 { if rekey {
// Get send Rekey // Get send Rekey
key, action = km.PopRekey() key, action = km.PopRekey()
...@@ -217,12 +217,12 @@ func handleE2ESending(session user.Session, ...@@ -217,12 +217,12 @@ func handleE2ESending(session user.Session,
key, action = km.PopKey() key, action = km.PopKey()
} }
if key != nil { if key != nil {
break end = true
} }
select { select {
case <-timeout: case <-timeout:
break end = true
default: default:
} }
} }
...@@ -288,7 +288,7 @@ func (m *Messaging) MessageReceiver(session user.Session, delay time.Duration) { ...@@ -288,7 +288,7 @@ func (m *Messaging) MessageReceiver(session user.Session, delay time.Duration) {
return return
default: default:
time.Sleep(delay) 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) decryptedMessages := m.receiveMessagesFromGateway(session, &pollingMessage)
if decryptedMessages != nil { if decryptedMessages != nil {
for i := range decryptedMessages { for i := range decryptedMessages {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment