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

Update go mod for e2eClient

parent c6e2354b
No related branches found
No related tags found
1 merge request!12Xx 4618/go mod maintanence
...@@ -2,9 +2,9 @@ package main ...@@ -2,9 +2,9 @@ package main
import ( import (
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/v4/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds" "gitlab.com/elixxir/client/v4/cmix/rounds"
"gitlab.com/elixxir/client/xxdk" "gitlab.com/elixxir/client/v4/xxdk"
"gitlab.com/elixxir/crypto/contact" "gitlab.com/elixxir/crypto/contact"
) )
......
module gitlab.com/elixxir/xxdk-examples/e2eServer module gitlab.com/elixxir/xxdk-examples/e2eServer
go 1.17 go 1.19
require ( require (
github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/jwalterweatherman v1.1.0
gitlab.com/elixxir/client v1.5.1-0.20220725172207-3ef87e8c794c gitlab.com/elixxir/client/v4 v4.6.1
gitlab.com/elixxir/crypto v0.0.7-0.20220606201132-c370d5039cea gitlab.com/elixxir/crypto v0.0.7-0.20230214180106-72841fd1e426
gitlab.com/elixxir/primitives v0.0.3-0.20220606195757-40f7a589347f gitlab.com/elixxir/primitives v0.0.3-0.20230214180039-9a25e2d3969c
gitlab.com/xx_network/primitives v0.0.4-0.20220712193914-aebd8544396e gitlab.com/xx_network/primitives v0.0.4-0.20230310205521-c440e68e34c4
) )
require ( require (
filippo.io/edwards25519 v1.0.0 // indirect
git.xx.network/elixxir/grpc-web-go-client v0.0.0-20230214175953-5b5a8c33d28a // indirect
github.com/badoux/checkmail v1.2.1 // indirect github.com/badoux/checkmail v1.2.1 // indirect
github.com/cloudflare/circl v1.1.0 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cloudflare/circl v1.2.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/elliotchance/orderedmap v1.4.0 // indirect github.com/elliotchance/orderedmap v1.4.0 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect
github.com/ttacon/libphonenumber v1.2.1 // indirect github.com/ttacon/libphonenumber v1.2.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/zeebo/blake3 v0.2.3 // indirect
gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f // indirect gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f // indirect
gitlab.com/elixxir/comms v0.0.4-0.20220603231314-e47e4af13326 // indirect gitlab.com/elixxir/comms v0.0.4-0.20230310205528-f06faa0d2f0b // indirect
gitlab.com/elixxir/ekv v0.1.7 // indirect gitlab.com/elixxir/ekv v0.2.1 // indirect
gitlab.com/xx_network/comms v0.0.4-0.20220630163702-f3d372ef6acd // indirect gitlab.com/xx_network/comms v0.0.4-0.20230214180029-5387fb85736d // indirect
gitlab.com/xx_network/crypto v0.0.5-0.20220606200528-3f886fe49e81 // indirect gitlab.com/xx_network/crypto v0.0.5-0.20230214003943-8a09396e95dd // indirect
gitlab.com/xx_network/ring v0.0.3-0.20220222211904-da613960ad93 // indirect gitlab.com/xx_network/ring v0.0.3-0.20220902183151-a7d3b15bc981 // indirect
golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed // indirect go.uber.org/atomic v1.10.0 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect golang.org/x/crypto v0.5.0 // indirect
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect golang.org/x/net v0.5.0 // indirect
golang.org/x/text v0.3.6 // indirect golang.org/x/sys v0.4.0 // indirect
google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect golang.org/x/text v0.6.0 // indirect
google.golang.org/grpc v1.42.0 // indirect google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect
google.golang.org/protobuf v1.27.1 // indirect google.golang.org/grpc v1.49.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
nhooyr.io/websocket v1.8.7 // indirect
src.agwa.name/tlshacks v0.0.0-20220518131152-d2c6f4e2b780 // indirect
) )
This diff is collapsed.
...@@ -3,7 +3,7 @@ package main ...@@ -3,7 +3,7 @@ package main
import ( import (
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/e2e/receive" "gitlab.com/elixxir/client/v4/e2e/receive"
) )
// listener implements the receive.Listener interface // listener implements the receive.Listener interface
......
...@@ -4,8 +4,8 @@ package main ...@@ -4,8 +4,8 @@ package main
import ( import (
"errors" "errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/catalog" "gitlab.com/elixxir/client/v4/catalog"
"gitlab.com/elixxir/client/xxdk" "gitlab.com/elixxir/client/v4/xxdk"
"gitlab.com/elixxir/primitives/fact" "gitlab.com/elixxir/primitives/fact"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"io/fs" "io/fs"
...@@ -22,7 +22,7 @@ func main() { ...@@ -22,7 +22,7 @@ func main() {
// Logging // Logging
initLog(1, "client.log") initLog(1, "client.log")
// Create a new client object------------------------------------------------------- // Create a new client object-----------------------------------------------
// Path to the recipient contact file // Path to the recipient contact file
recipientContactPath := "myE2eContact.xxc" recipientContactPath := "myE2eContact.xxc"
...@@ -31,9 +31,9 @@ func main() { ...@@ -31,9 +31,9 @@ func main() {
// You would ideally use a configuration tool to acquire these parameters // You would ideally use a configuration tool to acquire these parameters
statePath := "statePathRecipient" statePath := "statePathRecipient"
statePass := "password" statePass := "password"
// The following connects to mainnet. For historical reasons it is called a json file // The following connects to mainnet. For historical reasons it is called a
// but it is actually a marshalled file with a cryptographic signature attached. // json file but it is actually a marshalled file with a cryptographic
// This may change in the future. // signature attached. This may change in the future.
ndfURL := "https://elixxir-bins.s3.us-west-1.amazonaws.com/ndf/mainnet.json" ndfURL := "https://elixxir-bins.s3.us-west-1.amazonaws.com/ndf/mainnet.json"
certificatePath := "../mainnet.crt" certificatePath := "../mainnet.crt"
ndfPath := "ndf.json" ndfPath := "ndf.json"
...@@ -55,7 +55,8 @@ func main() { ...@@ -55,7 +55,8 @@ func main() {
jww.FATAL.Panicf("Failed to read certificate: %v", err) jww.FATAL.Panicf("Failed to read certificate: %v", err)
} }
ndfJSON, err = xxdk.DownloadAndVerifySignedNdfWithUrl(ndfURL, string(cert)) ndfJSON, err = xxdk.DownloadAndVerifySignedNdfWithUrl(ndfURL,
string(cert))
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to download NDF: %+v", err) jww.FATAL.Panicf("Failed to download NDF: %+v", err)
} }
...@@ -68,10 +69,11 @@ func main() { ...@@ -68,10 +69,11 @@ func main() {
} }
} }
// Login to your client session----------------------------------------------------- // Login to your client session---------------------------------------------
// Login with the same sessionPath and sessionPass used to call NewClient() // Login with the same sessionPath and sessionPass used to call NewClient()
net, err := xxdk.LoadCmix(statePath, []byte(statePass), xxdk.GetDefaultCMixParams()) net, err := xxdk.LoadCmix(statePath, []byte(statePass),
xxdk.GetDefaultCMixParams())
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to load state: %+v", err) jww.FATAL.Panicf("Failed to load state: %+v", err)
} }
...@@ -98,13 +100,14 @@ func main() { ...@@ -98,13 +100,14 @@ func main() {
params := xxdk.GetDefaultE2EParams() params := xxdk.GetDefaultE2EParams()
jww.INFO.Printf("Using E2E parameters: %+v", params) jww.INFO.Printf("Using E2E parameters: %+v", params)
confirmChan := make(chan contact.Contact, 5) confirmChan := make(chan contact.Contact, 5)
user, err := xxdk.Login(net, &auth{confirmChan: confirmChan}, identity, params) user, err := xxdk.Login(net, &auth{confirmChan: confirmChan}, identity,
params)
if err != nil { if err != nil {
jww.FATAL.Panicf("Unable to Login: %+v", err) jww.FATAL.Panicf("Unable to Login: %+v", err)
} }
e2eClient := user.GetE2E() e2eClient := user.GetE2E()
// Start network threads------------------------------------------------------------ // Start network threads----------------------------------------------------
// Set networkFollowerTimeout to a value of your choice (seconds) // Set networkFollowerTimeout to a value of your choice (seconds)
networkFollowerTimeout := 5 * time.Second networkFollowerTimeout := 5 * time.Second
...@@ -132,7 +135,8 @@ func main() { ...@@ -132,7 +135,8 @@ func main() {
// Create a tracker channel to be notified of network changes // Create a tracker channel to be notified of network changes
connected := make(chan bool, 10) connected := make(chan bool, 10)
// Provide a callback that will be signalled when network health status changes // Provide a callback that will be signalled when network health status
//changes
user.GetCmix().AddHealthCallback( user.GetCmix().AddHealthCallback(
func(isConnected bool) { func(isConnected bool) {
connected <- isConnected connected <- isConnected
...@@ -140,14 +144,15 @@ func main() { ...@@ -140,14 +144,15 @@ func main() {
// Wait until connected or crash on timeout // Wait until connected or crash on timeout
waitUntilConnected(connected) waitUntilConnected(connected)
// Register a listener for messages-------------------------------------------------- // Register a listener for messages-----------------------------------------
// Listen for all types of messages using catalog.NoType // Listen for all types of messages using catalog.NoType
// Listen for messages from all users using id.ZeroUser // Listen for messages from all users using id.ZeroUser
// User-defined behavior for message reception goes in the listener // User-defined behavior for message reception goes in the listener
_ = e2eClient.RegisterListener(&id.ZeroUser, catalog.NoType, listener{name: "e2e Message Listener"}) _ = e2eClient.RegisterListener(
&id.ZeroUser, catalog.NoType, listener{name: "e2e Message Listener"})
// Connect with the recipient-------------------------------------------------- // Connect with the recipient-----------------------------------------------
if recipientContactPath != "" { if recipientContactPath != "" {
// Wait for 30 seconds to ensure network connectivity // Wait for 30 seconds to ensure network connectivity
...@@ -160,8 +165,9 @@ func main() { ...@@ -160,8 +165,9 @@ func main() {
} }
// Imported "gitlab.com/elixxir/crypto/contact" // Imported "gitlab.com/elixxir/crypto/contact"
// which provides an `Unmarshal` function to convert the byte slice ([]byte) output // which provides an `Unmarshal` function to convert the byte slice
// of `ioutil.ReadFile()` to the `Contact` type expected by `RequestAuthenticatedChannel()` // ([]byte) output of `ioutil.ReadFile()` to the `Contact` type expected
// by `RequestAuthenticatedChannel()`
recipientContact, err := contact.Unmarshal(contactData) recipientContact, err := contact.Unmarshal(contactData)
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to get contact data: %+v", err) jww.FATAL.Panicf("Failed to get contact data: %+v", err)
...@@ -173,32 +179,37 @@ func main() { ...@@ -173,32 +179,37 @@ func main() {
if err != nil { if err != nil {
_, err = user.GetAuth().Request(recipientContact, fact.FactList{}) _, err = user.GetAuth().Request(recipientContact, fact.FactList{})
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to send contact request to %s: %+v", recipientContact.ID.String(), err) jww.FATAL.Panicf("Failed to send contact request to %s: %+v",
recipientContact.ID.String(), err)
} }
timeout := time.NewTimer(30 * time.Second) timeout := time.NewTimer(30 * time.Second)
select { select {
case pc := <-confirmChan: case pc := <-confirmChan:
if !pc.ID.Cmp(recipientContact.ID) { if !pc.ID.Cmp(recipientContact.ID) {
jww.FATAL.Panicf("Did not receive confirmation for the requested contact") jww.FATAL.Panicf(
"Did not receive confirmation for the requested contact")
} }
break break
case <-timeout.C: case <-timeout.C:
jww.FATAL.Panicf("Timed out waiting to receive confirmation of e2e relationship with partner") jww.FATAL.Panicf(
"Timed out waiting to receive confirmation of e2e relationship with partner")
} }
} }
// Send a message to the recipient---------------------------------------------------- // Send a message to the recipient--------------------------------------
// Test message // Test message
msgBody := "If this message is sent successfully, we'll have established contact with the recipient." msgBody := "If this message is sent successfully, we'll have established contact with the recipient."
roundIDs, messageID, timeSent, err := e2eClient.SendE2E(catalog.XxMessage, recipientContact.ID, []byte(msgBody), params.Base) sendReport, err := e2eClient.SendE2E(
catalog.XxMessage, recipientContact.ID, []byte(msgBody), params.Base)
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to send message: %+v", err) jww.FATAL.Panicf("Failed to send message: %+v", err)
} }
jww.INFO.Printf("Message %v sent in RoundIDs: %+v at %v", messageID, roundIDs, timeSent) jww.INFO.Printf("Message %v sent in RoundIDs: %+v at %v",
sendReport.MessageId, sendReport.RoundList, sendReport.SentTime)
} }
// Keep app running to receive messages----------------------------------------------- // Keep app running to receive messages-------------------------------------
// Wait until the user terminates the program // Wait until the user terminates the program
c := make(chan os.Signal) c := make(chan os.Signal)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment