diff --git a/cmd/root.go b/cmd/root.go index 285d0edb7e0c0a65906a94fcdfca1c8dad9abe37..49bba1c18f2fa86428191b5d7d873b0a2a6b7a33 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -132,7 +132,7 @@ var rootCmd = &cobra.Command{ swboard := client.GetSwitchboard() recvCh := make(chan message.Receive, 10) listenerID := swboard.RegisterChannel("raw", - switchboard.AnyUser(), message.Raw, recvCh) + switchboard.AnyUser(), message.Text, recvCh) jww.INFO.Printf("Message ListenerID: %v", listenerID) err := client.StartNetworkFollower() @@ -150,18 +150,22 @@ var rootCmd = &cobra.Command{ //recipientID := getUIDFromString(viper.GetString("destid")) recipientID := user.ID - msg := client.NewCMIXMessage(recipientID, []byte(msgBody)) - params := params.GetDefaultCMIX() + msg := message.Send{ + Recipient: recipientID, + Payload: []byte(msgBody), + MessageType: message.Text, + } + params := params.GetDefaultUnsafe() sendCnt := int(viper.GetUint("sendCount")) sendDelay := time.Duration(viper.GetUint("sendDelay")) for i := 0; i < sendCnt; i++ { fmt.Printf("Sending to %s: %s\n", recipientID, msgBody) - roundID, err := client.SendCMIX(msg, params) + roundIDs, err := client.SendUnsafe(msg, params) if err != nil { jww.FATAL.Panicf("%+v", err) } - jww.INFO.Printf("RoundID: %d\n", roundID) + jww.INFO.Printf("RoundIDs: %+v\n", roundIDs) time.Sleep(sendDelay * time.Millisecond) } diff --git a/network/message/sendUnsafe.go b/network/message/sendUnsafe.go index 92c3fbbf29f9cff68aaf585c4eca268184733d60..bda6512b49f2511bc3af1f12c4f0312916e74aea 100644 --- a/network/message/sendUnsafe.go +++ b/network/message/sendUnsafe.go @@ -42,6 +42,7 @@ func (m *Manager) SendUnsafe(msg message.Send, param params.Unsafe) ([]id.Round, for i, p := range partitions { msgCmix := format.NewMessage(m.Session.Cmix().GetGroup().GetP().ByteLen()) msgCmix.SetContents(p) + msgCmix.SetRecipientID(msg.Recipient) e2e.SetUnencrypted(msgCmix, msg.Recipient) wg.Add(1) go func(i int) { @@ -54,6 +55,8 @@ func (m *Manager) SendUnsafe(msg message.Send, param params.Unsafe) ([]id.Round, }(i) } + wg.Wait() + //see if any parts failed to send numFail, errRtn := getSendErrors(errCh) if numFail > 0 { diff --git a/network/send.go b/network/send.go index 904776c9dceca9af15e6814ce16ccd0162e66382..9964d7fd4abebe25c6733893877c4127c302c0ad 100644 --- a/network/send.go +++ b/network/send.go @@ -37,7 +37,7 @@ func (m *manager) SendUnsafe(msg message.Send, param params.Unsafe) ([]id.Round, " to end encryption, they have limited security and privacy " + "preserving properties") - return m.SendUnsafe(msg, param) + return m.message.SendUnsafe(msg, param) } // SendE2E sends an end-to-end payload to the provided recipient with