From 2fbd5553798d45f6980a7d382add171553bfa763 Mon Sep 17 00:00:00 2001 From: joshemb <josh@elixxir.io> Date: Mon, 8 Aug 2022 15:03:32 -0700 Subject: [PATCH] Revert "Fix contact marshal mismatch bug" This reverts commit abc57b7293a39f5e7519118a09e05e1691b4538a. --- bindings/ud.go | 10 +++++----- ud/alternate.go | 21 ++++++++++----------- ud/manager.go | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/bindings/ud.go b/bindings/ud.go index d3652056f..da1b196a2 100644 --- a/bindings/ud.go +++ b/bindings/ud.go @@ -125,13 +125,13 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus, } // Construct callback - udNetworkStatusFn := func() xxdk.Status { + UdNetworkStatusFn := func() xxdk.Status { return xxdk.Status(follower.UdNetworkStatus()) } // Build manager u, err := ud.LoadOrNewManager(user.api, user.api.GetComms(), - udNetworkStatusFn, username, registrationValidationSignature) + UdNetworkStatusFn, username, registrationValidationSignature) if err != nil { return nil, err } @@ -156,7 +156,7 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus, // be nil, however UD may return an error in some cases (e.g. in a production level environment). // - altCert is the TLS certificate for the alternate UD server. // - altAddress is the IP address of the alternate UD server. -// - marshalledContact is a JSON marshalled contact.Contact. +// - marshalledContact is the data within a marshalled contact.Contact. // // Returns // - A Manager object which is registered to the specified alternate UD service. @@ -172,13 +172,13 @@ func LoadOrNewAlternateUserDiscovery(e2eID int, follower UdNetworkStatus, } // Construct callback - udNetworkStatusFn := func() xxdk.Status { + UdNetworkStatusFn := func() xxdk.Status { return xxdk.Status(follower.UdNetworkStatus()) } // Build manager u, err := ud.LoadOrNewAlternateUserDiscovery(user.api, user.api.GetComms(), - udNetworkStatusFn, username, registrationValidationSignature, + UdNetworkStatusFn, username, registrationValidationSignature, altCert, altAddress, marshalledContact) if err != nil { return nil, err diff --git a/ud/alternate.go b/ud/alternate.go index f0f1a50e6..4f0013bfc 100644 --- a/ud/alternate.go +++ b/ud/alternate.go @@ -1,10 +1,10 @@ package ud import ( - "encoding/json" "github.com/pkg/errors" "gitlab.com/elixxir/crypto/contact" "gitlab.com/xx_network/comms/connect" + "gitlab.com/xx_network/primitives/id" ) // alternateUd is an alternative user discovery service. @@ -26,28 +26,27 @@ func (m *Manager) setAlternateUserDiscovery(altCert, altAddress, params := connect.GetDefaultHostParams() params.AuthEnabled = false - c := &contact.Contact{} - err := json.Unmarshal(contactFile, c) + udIdBytes, dhPubKey, err := contact.ReadContactFromFile(contactFile) if err != nil { - return errors.Errorf("Failed to unmarshal contact file: %v", err) + return err + } + + udID, err := id.Unmarshal(udIdBytes) + if err != nil { + return err } // Add a new host and return it if it does not already exist - host, err := m.comms.AddHost(c.ID, string(altAddress), + host, err := m.comms.AddHost(udID, string(altAddress), altCert, params) if err != nil { return errors.WithMessage(err, "User Discovery host object could "+ "not be constructed.") } - dhPubJson, err := c.DhPubKey.MarshalJSON() - if err != nil { - return errors.Errorf("Failed to marshal Diffie-Helman public key: %v", err) - } - m.alternativeUd = &alternateUd{ host: host, - dhPubKey: dhPubJson, + dhPubKey: dhPubKey, } return nil diff --git a/ud/manager.go b/ud/manager.go index 9545ed748..c1d51d002 100644 --- a/ud/manager.go +++ b/ud/manager.go @@ -140,7 +140,7 @@ func NewManagerFromBackup(user udE2e, comms Comms, follower udNetworkStatus, // be nil, however UD may return an error in some cases (e.g. in a production level environment). // - altCert is the TLS certificate for the alternate UD server. // - altAddress is the IP address of the alternate UD server. -// - marshalledContact is a JSON marshalled contact.Contact. +// - marshalledContact is the data within a marshalled contact.Contact. // // Returns // - A Manager object which is registered to the specified alternate UD service. -- GitLab