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

Revert "Fix contact marshal mismatch bug"

This reverts commit abc57b72.
parent abc57b72
No related branches found
No related tags found
3 merge requests!510Release,!324Fix contact marshal mismatch bug,!323Xx 4019/new or load alt ud
...@@ -125,13 +125,13 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus, ...@@ -125,13 +125,13 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus,
} }
// Construct callback // Construct callback
udNetworkStatusFn := func() xxdk.Status { UdNetworkStatusFn := func() xxdk.Status {
return xxdk.Status(follower.UdNetworkStatus()) return xxdk.Status(follower.UdNetworkStatus())
} }
// Build manager // Build manager
u, err := ud.LoadOrNewManager(user.api, user.api.GetComms(), u, err := ud.LoadOrNewManager(user.api, user.api.GetComms(),
udNetworkStatusFn, username, registrationValidationSignature) UdNetworkStatusFn, username, registrationValidationSignature)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -156,7 +156,7 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus, ...@@ -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). // 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. // - altCert is the TLS certificate for the alternate UD server.
// - altAddress is the IP address of 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 // Returns
// - A Manager object which is registered to the specified alternate UD service. // - A Manager object which is registered to the specified alternate UD service.
...@@ -172,13 +172,13 @@ func LoadOrNewAlternateUserDiscovery(e2eID int, follower UdNetworkStatus, ...@@ -172,13 +172,13 @@ func LoadOrNewAlternateUserDiscovery(e2eID int, follower UdNetworkStatus,
} }
// Construct callback // Construct callback
udNetworkStatusFn := func() xxdk.Status { UdNetworkStatusFn := func() xxdk.Status {
return xxdk.Status(follower.UdNetworkStatus()) return xxdk.Status(follower.UdNetworkStatus())
} }
// Build manager // Build manager
u, err := ud.LoadOrNewAlternateUserDiscovery(user.api, user.api.GetComms(), u, err := ud.LoadOrNewAlternateUserDiscovery(user.api, user.api.GetComms(),
udNetworkStatusFn, username, registrationValidationSignature, UdNetworkStatusFn, username, registrationValidationSignature,
altCert, altAddress, marshalledContact) altCert, altAddress, marshalledContact)
if err != nil { if err != nil {
return nil, err return nil, err
......
package ud package ud
import ( import (
"encoding/json"
"github.com/pkg/errors" "github.com/pkg/errors"
"gitlab.com/elixxir/crypto/contact" "gitlab.com/elixxir/crypto/contact"
"gitlab.com/xx_network/comms/connect" "gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/primitives/id"
) )
// alternateUd is an alternative user discovery service. // alternateUd is an alternative user discovery service.
...@@ -26,28 +26,27 @@ func (m *Manager) setAlternateUserDiscovery(altCert, altAddress, ...@@ -26,28 +26,27 @@ func (m *Manager) setAlternateUserDiscovery(altCert, altAddress,
params := connect.GetDefaultHostParams() params := connect.GetDefaultHostParams()
params.AuthEnabled = false params.AuthEnabled = false
c := &contact.Contact{} udIdBytes, dhPubKey, err := contact.ReadContactFromFile(contactFile)
err := json.Unmarshal(contactFile, c)
if err != nil { 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 // 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) altCert, params)
if err != nil { if err != nil {
return errors.WithMessage(err, "User Discovery host object could "+ return errors.WithMessage(err, "User Discovery host object could "+
"not be constructed.") "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{ m.alternativeUd = &alternateUd{
host: host, host: host,
dhPubKey: dhPubJson, dhPubKey: dhPubKey,
} }
return nil return nil
......
...@@ -140,7 +140,7 @@ func NewManagerFromBackup(user udE2e, comms Comms, follower udNetworkStatus, ...@@ -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). // 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. // - altCert is the TLS certificate for the alternate UD server.
// - altAddress is the IP address of 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 // Returns
// - A Manager object which is registered to the specified alternate UD service. // - A Manager object which is registered to the specified alternate UD service.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment