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

Fix contact marshal mismatch bug

parent 95f96c9e
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,
}
// 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 the data within a marshalled contact.Contact.
// - marshalledContact is a JSON 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
......
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,27 +26,28 @@ func (m *Manager) setAlternateUserDiscovery(altCert, altAddress,
params := connect.GetDefaultHostParams()
params.AuthEnabled = false
udIdBytes, dhPubKey, err := contact.ReadContactFromFile(contactFile)
c := &contact.Contact{}
err := json.Unmarshal(contactFile, c)
if err != nil {
return err
}
udID, err := id.Unmarshal(udIdBytes)
if err != nil {
return err
return errors.Errorf("Failed to unmarshal contact file: %v", err)
}
// Add a new host and return it if it does not already exist
host, err := m.comms.AddHost(udID, string(altAddress),
host, err := m.comms.AddHost(c.ID, 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: dhPubKey,
dhPubKey: dhPubJson,
}
return nil
......
......@@ -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 the data within a marshalled contact.Contact.
// - marshalledContact is a JSON marshalled contact.Contact.
//
// Returns
// - 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