Skip to content
Snippets Groups Projects
Commit 4f389b6b authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Thread through the params objects in bindings so that they are settable

parent 24fc1395
No related branches found
No related tags found
2 merge requests!510Release,!262Add params options to bindings
......@@ -11,6 +11,7 @@ import (
"sync"
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/connect"
"gitlab.com/elixxir/crypto/contact"
)
......@@ -34,8 +35,12 @@ func (_ *AuthenticatedConnection) IsAuthenticated() bool {
// connection with the server). Once a connect.Connection has been established
// with the server and then authenticate their identity to the server.
// accepts a marshalled ReceptionIdentity and contact.Contact object
func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact []byte) (*AuthenticatedConnection, error) {
paramsJSON := GetDefaultE2EParams()
func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact,
e2eParamsJSON []byte) (*AuthenticatedConnection, error) {
if len(e2eParamsJSON) == 0 {
jww.WARN.Printf("e2e params not specified, using defaults...")
e2eParamsJSON = GetDefaultE2EParams()
}
cont, err := contact.Unmarshal(recipientContact)
if err != nil {
......@@ -47,7 +52,7 @@ func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact []byte) (*A
return nil, err
}
params, err := parseE2EParams(paramsJSON)
params, err := parseE2EParams(e2eParamsJSON)
if err != nil {
return nil, err
}
......
......@@ -11,6 +11,7 @@ import (
"sync"
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/xxdk"
......@@ -39,8 +40,13 @@ func (e *E2e) GetID() int {
// LoginE2e creates and returns a new E2e object and adds it to the e2eTrackerSingleton
// identity should be created via MakeIdentity() and passed in here
// If callbacks is left nil, a default auth.Callbacks will be used
func LoginE2e(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error) {
paramsJSON := GetDefaultE2EParams()
func LoginE2e(cmixId int, callbacks AuthCallbacks, identity,
e2eParamsJSON []byte) (*E2e, error) {
if len(e2eParamsJSON) == 0 {
jww.WARN.Printf("e2e params not specified, using defaults...")
e2eParamsJSON = GetDefaultE2EParams()
}
cmix, err := cmixTrackerSingleton.get(cmixId)
if err != nil {
return nil, err
......@@ -58,7 +64,7 @@ func LoginE2e(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error
authCallbacks = &authCallback{bindingsCbs: callbacks}
}
params, err := parseE2EParams(paramsJSON)
params, err := parseE2EParams(e2eParamsJSON)
if err != nil {
return nil, err
}
......@@ -74,8 +80,13 @@ func LoginE2e(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error
// LoginE2eEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton
// identity should be created via MakeIdentity() and passed in here
// If callbacks is left nil, a default auth.Callbacks will be used
func LoginE2eEphemeral(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error) {
paramsJSON := GetDefaultE2EParams()
func LoginE2eEphemeral(cmixId int, callbacks AuthCallbacks, identity,
e2eParamsJSON []byte) (*E2e, error) {
if len(e2eParamsJSON) == 0 {
jww.WARN.Printf("e2e params not specified, using defaults...")
e2eParamsJSON = GetDefaultE2EParams()
}
cmix, err := cmixTrackerSingleton.get(cmixId)
if err != nil {
return nil, err
......@@ -93,7 +104,7 @@ func LoginE2eEphemeral(cmixId int, callbacks AuthCallbacks, identity []byte) (*E
authCallbacks = &authCallback{bindingsCbs: callbacks}
}
params, err := parseE2EParams(paramsJSON)
params, err := parseE2EParams(e2eParamsJSON)
if err != nil {
return nil, err
}
......@@ -111,8 +122,12 @@ func LoginE2eEphemeral(cmixId int, callbacks AuthCallbacks, identity []byte) (*E
// If callbacks is left nil, a default auth.Callbacks will be used
// This function is designed to maintain backwards compatibility with previous xx messenger designs
// and should not be used for other purposes
func LoginE2eLegacy(cmixId int, callbacks AuthCallbacks) (*E2e, error) {
paramsJSON := GetDefaultE2EParams()
func LoginE2eLegacy(cmixId int, callbacks AuthCallbacks, e2eParamsJSON []byte) (*E2e, error) {
if len(e2eParamsJSON) == 0 {
jww.WARN.Printf("e2e params not specified, using defaults...")
e2eParamsJSON = GetDefaultE2EParams()
}
cmix, err := cmixTrackerSingleton.get(cmixId)
if err != nil {
return nil, err
......@@ -125,7 +140,7 @@ func LoginE2eLegacy(cmixId int, callbacks AuthCallbacks) (*E2e, error) {
authCallbacks = &authCallback{bindingsCbs: callbacks}
}
params, err := parseE2EParams(paramsJSON)
params, err := parseE2EParams(e2eParamsJSON)
if err != nil {
return nil, err
}
......
......@@ -10,7 +10,7 @@ package bindings
import (
"encoding/json"
"gitlab.com/elixxir/client/e2e"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/restlike"
"gitlab.com/elixxir/client/restlike/connect"
)
......@@ -35,8 +35,12 @@ type RestlikeMessage struct {
// RestlikeRequest performs a normal restlike request
// request - marshalled RestlikeMessage
// Returns marshalled result RestlikeMessage
func RestlikeRequest(clientID, connectionID int, request []byte) ([]byte, error) {
paramsJSON := GetDefaultE2EParams()
func RestlikeRequest(clientID, connectionID int, request,
e2eParamsJSON []byte) ([]byte, error) {
if len(e2eParamsJSON) == 0 {
jww.WARN.Printf("restlike params unspecified, using defaults")
e2eParamsJSON = GetDefaultE2EParams()
}
cl, err := cmixTrackerSingleton.get(clientID)
if err != nil {
......@@ -47,7 +51,7 @@ func RestlikeRequest(clientID, connectionID int, request []byte) ([]byte, error)
return nil, err
}
params, err := parseE2EParams(paramsJSON)
params, err := parseE2EParams(e2eParamsJSON)
if err != nil {
return nil, err
}
......@@ -86,7 +90,17 @@ func RestlikeRequest(clientID, connectionID int, request []byte) ([]byte, error)
// RestlikeRequestAuth performs an authenticated restlike request
// request - marshalled RestlikeMessage
// Returns marshalled result RestlikeMessage
func RestlikeRequestAuth(clientID int, authConnectionID int, request []byte) ([]byte, error) {
func RestlikeRequestAuth(clientID int, authConnectionID int, request,
e2eParamsJSON []byte) ([]byte, error) {
if len(e2eParamsJSON) == 0 {
jww.WARN.Printf("restlike params unspecified, using defaults")
e2eParamsJSON = GetDefaultE2EParams()
}
params, err := parseE2EParams(e2eParamsJSON)
if err != nil {
return nil, err
}
cl, err := cmixTrackerSingleton.get(clientID)
if err != nil {
return nil, err
......@@ -111,7 +125,7 @@ func RestlikeRequestAuth(clientID int, authConnectionID int, request []byte) ([]
result, err := c.Request(restlike.Method(msg.Method), restlike.URI(msg.URI), msg.Content, &restlike.Headers{
Headers: msg.Headers,
Version: msg.Version,
}, e2e.GetDefaultParams())
}, params.Base)
if err != nil {
return nil, err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment