Skip to content
Snippets Groups Projects
Commit f30748a7 authored by Josh Brooks's avatar Josh Brooks
Browse files

Only verify auth sends on a verify-sends flag

parent 9c32d668
Branches
Tags
2 merge requests!510Release,!235Verify sends for auth messages
...@@ -258,7 +258,6 @@ var rootCmd = &cobra.Command{ ...@@ -258,7 +258,6 @@ var rootCmd = &cobra.Command{
// Send Messages // Send Messages
msgBody := viper.GetString("message") msgBody := viper.GetString("message")
time.Sleep(10 * time.Second) time.Sleep(10 * time.Second)
// Accept auth request for this recipient // Accept auth request for this recipient
...@@ -268,12 +267,16 @@ var rootCmd = &cobra.Command{ ...@@ -268,12 +267,16 @@ var rootCmd = &cobra.Command{
if viper.GetBool("accept-channel") { if viper.GetBool("accept-channel") {
done := make(chan struct{}, 1) done := make(chan struct{}, 1)
retryChan := make(chan struct{}, 1) retryChan := make(chan struct{}, 1)
for {
if viper.GetBool("verify-sends") {
for {
rid := acceptChannel(client, recipientID) rid := acceptChannel(client, recipientID)
// Verify message sends were successful
// Construct the callback function which // Construct the callback function which
// verifies successful message send or retries // verifies successful message send or retries
f := func(allRoundsSucceeded, timedOut bool, rounds map[id.Round]cmix.RoundResult) { f := func(allRoundsSucceeded, timedOut bool,
rounds map[id.Round]cmix.RoundResult) {
if !allRoundsSucceeded { if !allRoundsSucceeded {
retryChan <- struct{}{} retryChan <- struct{}{}
} else { } else {
...@@ -293,8 +296,9 @@ var rootCmd = &cobra.Command{ ...@@ -293,8 +296,9 @@ var rootCmd = &cobra.Command{
select { select {
case <-retryChan: case <-retryChan:
// On a retry, go to the top of the loop // On a retry, go to the top of the loop
jww.DEBUG.Printf("Confirmation message for relationship with %s "+ jww.DEBUG.Printf("Confirmation message for relationship"+
"were not sent successfully, resending messages...", recipientID) " with %s were not sent successfully, resending "+
"messages...", recipientID)
continue continue
case <-done: case <-done:
// Close channels on verification success // Close channels on verification success
...@@ -304,6 +308,9 @@ var rootCmd = &cobra.Command{ ...@@ -304,6 +308,9 @@ var rootCmd = &cobra.Command{
} }
break break
} }
} else {
acceptChannel(client, recipientID)
}
// Do not wait for channel confirmations if we // Do not wait for channel confirmations if we
// accepted one // accepted one
...@@ -318,7 +325,6 @@ var rootCmd = &cobra.Command{ ...@@ -318,7 +325,6 @@ var rootCmd = &cobra.Command{
// Send unsafe messages or not? // Send unsafe messages or not?
unsafe := viper.GetBool("unsafe") unsafe := viper.GetBool("unsafe")
sendAuthReq := viper.GetBool("send-auth-request") sendAuthReq := viper.GetBool("send-auth-request")
if !unsafe && !authConfirmed && !isPrecanPartner && if !unsafe && !authConfirmed && !isPrecanPartner &&
sendAuthReq { sendAuthReq {
...@@ -441,8 +447,10 @@ var rootCmd = &cobra.Command{ ...@@ -441,8 +447,10 @@ var rootCmd = &cobra.Command{
// Construct the callback function which // Construct the callback function which
// verifies successful message send or retries // verifies successful message send or retries
f := func(allRoundsSucceeded, timedOut bool, rounds map[id.Round]cmix.RoundResult) { f := func(allRoundsSucceeded, timedOut bool,
printRoundResults(allRoundsSucceeded, timedOut, rounds, roundIDs, payload, recipientID) rounds map[id.Round]cmix.RoundResult) {
printRoundResults(allRoundsSucceeded, timedOut,
rounds, roundIDs, payload, recipientID)
if !allRoundsSucceeded { if !allRoundsSucceeded {
retryChan <- struct{}{} retryChan <- struct{}{}
} else { } else {
...@@ -798,6 +806,7 @@ func addAuthenticatedChannel(client *messenger.Client, recipientID *id.ID, ...@@ -798,6 +806,7 @@ func addAuthenticatedChannel(client *messenger.Client, recipientID *id.ID,
done := make(chan struct{}, 1) done := make(chan struct{}, 1)
paramsE2E := e2e.GetDefaultParams() paramsE2E := e2e.GetDefaultParams()
roundTimeout := paramsE2E.CMIXParams.SendTimeout roundTimeout := paramsE2E.CMIXParams.SendTimeout
if viper.GetBool("verify-sends") {
for { for {
// Construct the callback function which // Construct the callback function which
// verifies successful message send or retries // verifies successful message send or retries
...@@ -837,6 +846,13 @@ func addAuthenticatedChannel(client *messenger.Client, recipientID *id.ID, ...@@ -837,6 +846,13 @@ func addAuthenticatedChannel(client *messenger.Client, recipientID *id.ID,
} }
break break
} }
} else {
_, err := client.GetAuth().Request(recipientContact,
me.Facts)
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
}
} else { } else {
jww.ERROR.Printf("Could not add auth channel for %s", jww.ERROR.Printf("Could not add auth channel for %s",
......
...@@ -105,5 +105,6 @@ func readContact() contact.Contact { ...@@ -105,5 +105,6 @@ func readContact() contact.Contact {
} }
jww.INFO.Printf("CONTACTPUBKEY READ: %s", jww.INFO.Printf("CONTACTPUBKEY READ: %s",
c.DhPubKey.TextVerbose(16, 0)) c.DhPubKey.TextVerbose(16, 0))
jww.INFO.Printf("Contact ID: %s", c.ID)
return c return c
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment