Skip to content
Snippets Groups Projects
Commit 73731b08 authored by Jonah Husson's avatar Jonah Husson
Browse files

Merge branch 'release' into hotfix/bindings-timeout

parents ee56c780 362a4bc9
Branches
Tags
2 merge requests!510Release,!249Increase bindings timeout in cmix params to 45 seconds
...@@ -6,6 +6,17 @@ ...@@ -6,6 +6,17 @@
package bindings package bindings
import (
"encoding/json"
"fmt"
"gitlab.com/elixxir/client/catalog"
"gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id"
)
// IdList is a wrapper for a list of marshalled id.ID objects // IdList is a wrapper for a list of marshalled id.ID objects
type IdList struct { type IdList struct {
Ids [][]byte Ids [][]byte
...@@ -22,168 +33,167 @@ type E2ESendReport struct { ...@@ -22,168 +33,167 @@ type E2ESendReport struct {
Timestamp int64 Timestamp int64
} }
// // GetReceptionID returns the marshalled default IDs
//// GetReceptionID returns the marshalled default IDs // Returns:
//// Returns: // - []byte - the marshalled bytes of the id.ID object.
//// - []byte - the marshalled bytes of the id.ID object. func (e *E2e) GetReceptionID() []byte {
//func (e *E2e) GetReceptionID() []byte { return e.api.GetE2E().GetReceptionID().Marshal()
// return e.api.GetE2E().GetReceptionID().Marshal() }
//}
// // GetAllPartnerIDs returns a marshalled list of all partner IDs that the user has
//// GetAllPartnerIDs returns a marshalled list of all partner IDs that the user has // an E2E relationship with.
//// an E2E relationship with. // Returns:
//// Returns: // - []byte - the marshalled bytes of the IdList object.
//// - []byte - the marshalled bytes of the IdList object. func (e *E2e) GetAllPartnerIDs() ([]byte, error) {
//func (e *E2e) GetAllPartnerIDs() ([]byte, error) { partnerIds := e.api.GetE2E().GetAllPartnerIDs()
// partnerIds := e.api.GetE2E().GetAllPartnerIDs() convertedIds := make([][]byte, len(partnerIds))
// convertedIds := make([][]byte, len(partnerIds)) for i, partnerId := range partnerIds {
// for i, partnerId := range partnerIds { convertedIds[i] = partnerId.Marshal()
// convertedIds[i] = partnerId.Marshal() }
// } return json.Marshal(IdList{Ids: convertedIds})
// return json.Marshal(IdList{Ids: convertedIds}) }
//}
// // PayloadSize Returns the max payload size for a partitionable E2E
//// PayloadSize Returns the max payload size for a partitionable E2E // message
//// message func (e *E2e) PayloadSize() int {
//func (e *E2e) PayloadSize() int { return int(e.api.GetE2E().PayloadSize())
// return int(e.api.GetE2E().PayloadSize()) }
//}
// // SecondPartitionSize returns the max partition payload size for all
//// SecondPartitionSize returns the max partition payload size for all // payloads after the first payload
//// payloads after the first payload func (e *E2e) SecondPartitionSize() int {
//func (e *E2e) SecondPartitionSize() int { return int(e.api.GetE2E().SecondPartitionSize())
// return int(e.api.GetE2E().SecondPartitionSize()) }
//}
// // PartitionSize returns the partition payload size for the given
//// PartitionSize returns the partition payload size for the given // payload index. The first payload is index 0.
//// payload index. The first payload is index 0. func (e *E2e) PartitionSize(payloadIndex int) int {
//func (e *E2e) PartitionSize(payloadIndex int) int { return int(e.api.GetE2E().PartitionSize(uint(payloadIndex)))
// return int(e.api.GetE2E().PartitionSize(uint(payloadIndex))) }
//}
// // FirstPartitionSize returns the max partition payload size for the
//// FirstPartitionSize returns the max partition payload size for the // first payload
//// first payload func (e *E2e) FirstPartitionSize() int {
//func (e *E2e) FirstPartitionSize() int { return int(e.api.GetE2E().FirstPartitionSize())
// return int(e.api.GetE2E().FirstPartitionSize()) }
//}
// // GetHistoricalDHPrivkey returns the user's marshalled Historical DH Private Key
//// GetHistoricalDHPrivkey returns the user's marshalled Historical DH Private Key // Returns:
//// Returns: // - []byte - the marshalled bytes of the cyclic.Int object.
//// - []byte - the marshalled bytes of the cyclic.Int object. func (e *E2e) GetHistoricalDHPrivkey() ([]byte, error) {
//func (e *E2e) GetHistoricalDHPrivkey() ([]byte, error) { return e.api.GetE2E().GetHistoricalDHPrivkey().MarshalJSON()
// return e.api.GetE2E().GetHistoricalDHPrivkey().MarshalJSON() }
//}
// // GetHistoricalDHPubkey returns the user's marshalled Historical DH
//// GetHistoricalDHPubkey returns the user's marshalled Historical DH // Public Key
//// Public Key // Returns:
//// Returns: // - []byte - the marshalled bytes of the cyclic.Int object.
//// - []byte - the marshalled bytes of the cyclic.Int object. func (e *E2e) GetHistoricalDHPubkey() ([]byte, error) {
//func (e *E2e) GetHistoricalDHPubkey() ([]byte, error) { return e.api.GetE2E().GetHistoricalDHPubkey().MarshalJSON()
// return e.api.GetE2E().GetHistoricalDHPubkey().MarshalJSON() }
//}
// // HasAuthenticatedChannel returns true if an authenticated channel with the
//// HasAuthenticatedChannel returns true if an authenticated channel with the // partner exists, otherwise returns false
//// partner exists, otherwise returns false // Parameters:
//// Parameters: // - partnerId - the marshalled bytes of the id.ID object.
//// - partnerId - the marshalled bytes of the id.ID object. func (e *E2e) HasAuthenticatedChannel(partnerId []byte) (bool, error) {
//func (e *E2e) HasAuthenticatedChannel(partnerId []byte) (bool, error) { partner, err := id.Unmarshal(partnerId)
// partner, err := id.Unmarshal(partnerId) if err != nil {
// if err != nil { return false, err
// return false, err }
// } return e.api.GetE2E().HasAuthenticatedChannel(partner), nil
// return e.api.GetE2E().HasAuthenticatedChannel(partner), nil }
//}
// // RemoveService removes all services for the given tag
//// RemoveService removes all services for the given tag func (e *E2e) RemoveService(tag string) error {
//func (e *E2e) RemoveService(tag string) error { return e.api.GetE2E().RemoveService(tag)
// return e.api.GetE2E().RemoveService(tag) }
//}
// // SendE2E send a message containing the payload to the
//// SendE2E send a message containing the payload to the // recipient of the passed message type, per the given
//// recipient of the passed message type, per the given // parameters - encrypted with end-to-end encryption.
//// parameters - encrypted with end-to-end encryption. // Default parameters can be retrieved through
//// Default parameters can be retrieved through // Parameters:
//// Parameters: // - recipientId - the marshalled bytes of the id.ID object.
//// - recipientId - the marshalled bytes of the id.ID object. // - e2eParams - the marshalled bytes of the e2e.Params object.
//// - e2eParams - the marshalled bytes of the e2e.Params object. // Returns:
//// Returns: // - []byte - the marshalled bytes of the E2ESendReport object.
//// - []byte - the marshalled bytes of the E2ESendReport object. func (e *E2e) SendE2E(messageType int, recipientId, payload,
//func (e *E2e) SendE2E(messageType int, recipientId, payload, e2eParams []byte) ([]byte, error) {
// e2eParams []byte) ([]byte, error) {
// params := e2e.GetDefaultParams()
// params := e2e.GetDefaultParams() err := params.UnmarshalJSON(e2eParams)
// err := params.UnmarshalJSON(e2eParams) if err != nil {
// if err != nil { return nil, err
// return nil, err }
// } recipient, err := id.Unmarshal(recipientId)
// recipient, err := id.Unmarshal(recipientId) if err != nil {
// if err != nil { return nil, err
// return nil, err }
// }
// roundIds, messageId, ts, err := e.api.GetE2E().SendE2E(catalog.MessageType(messageType), recipient, payload, params)
// roundIds, messageId, ts, err := e.api.GetE2E().SendE2E(catalog.MessageType(messageType), recipient, payload, params) if err != nil {
// if err != nil { return nil, err
// return nil, err }
// }
// result := E2ESendReport{
// result := E2ESendReport{ RoundsList: makeRoundsList(roundIds),
// RoundsList: makeRoundsList(roundIds), MessageID: messageId.Marshal(),
// MessageID: messageId.Marshal(), Timestamp: ts.UnixNano(),
// Timestamp: ts.UnixNano(), }
// } return json.Marshal(result)
// return json.Marshal(result) }
//}
// // AddService adds a service for all partners of the given
//// AddService adds a service for all partners of the given // tag, which will call back on the given processor. These can
//// tag, which will call back on the given processor. These can // be sent to using the tag fields in the Params Object
//// be sent to using the tag fields in the Params Object // Passing nil for the processor allows you to create a
//// Passing nil for the processor allows you to create a // service which is never called but will be visible by
//// service which is never called but will be visible by // notifications. Processes added this way are generally not
//// notifications. Processes added this way are generally not // end-to-end encrypted messages themselves, but other
//// end-to-end encrypted messages themselves, but other // protocols which piggyback on e2e relationships to start
//// protocols which piggyback on e2e relationships to start // communication
//// communication func (e *E2e) AddService(tag string, processor Processor) error {
//func (e *E2e) AddService(tag string, processor Processor) error { return e.api.GetE2E().AddService(tag, &messageProcessor{bindingsCbs: processor})
// return e.api.GetE2E().AddService(tag, &messageProcessor{bindingsCbs: processor}) }
//}
// // Processor is the bindings-specific interface for message.Processor methods.
//// Processor is the bindings-specific interface for message.Processor methods. type Processor interface {
//type Processor interface { Process(message []byte, receptionId []byte, ephemeralId int64, roundId int64)
// Process(message []byte, receptionId []byte, ephemeralId int64, roundId int64) fmt.Stringer
// fmt.Stringer }
//}
// // messageProcessor implements Processor as a way of obtaining
//// messageProcessor implements Processor as a way of obtaining // a message.Processor over the bindings
//// a message.Processor over the bindings type messageProcessor struct {
//type messageProcessor struct { bindingsCbs Processor
// bindingsCbs Processor }
//}
// // convertAuthCallbacks turns an auth.Callbacks into an AuthCallbacks
//// convertAuthCallbacks turns an auth.Callbacks into an AuthCallbacks func convertProcessor(msg format.Message,
//func convertProcessor(msg format.Message, receptionID receptionID.EphemeralIdentity,
// receptionID receptionID.EphemeralIdentity, round rounds.Round) (message []byte, receptionId []byte, ephemeralId int64, roundId int64) {
// round rounds.Round) (message []byte, receptionId []byte, ephemeralId int64, roundId int64) {
// message = msg.Marshal()
// message = msg.Marshal() receptionId = receptionID.Source.Marshal()
// receptionId = receptionID.Source.Marshal() ephemeralId = int64(receptionID.EphId.UInt64())
// ephemeralId = int64(receptionID.EphId.UInt64()) roundId = int64(round.ID)
// roundId = int64(round.ID) return
// return }
//}
// // Process decrypts and hands off the message to its internal down stream
//// Process decrypts and hands off the message to its internal down stream // message processing system.
//// message processing system. // CRITICAL: Fingerprints should never be used twice. Process must denote,
//// CRITICAL: Fingerprints should never be used twice. Process must denote, // in long term storage, usage of a fingerprint and that fingerprint must
//// in long term storage, usage of a fingerprint and that fingerprint must // not be added again during application load.
//// not be added again during application load. // It is a security vulnerability to reuse a fingerprint. It leaks privacy
//// It is a security vulnerability to reuse a fingerprint. It leaks privacy // and can lead to compromise of message contents and integrity.
//// and can lead to compromise of message contents and integrity. func (m *messageProcessor) Process(msg format.Message,
//func (m *messageProcessor) Process(msg format.Message, receptionID receptionID.EphemeralIdentity, roundId rounds.Round) {
// receptionID receptionID.EphemeralIdentity, roundId rounds.Round) { m.bindingsCbs.Process(convertProcessor(msg, receptionID, roundId))
// m.bindingsCbs(convertProcessor(msg, receptionID, roundId)) }
//}
// // Stringer interface for debugging
//// Stringer interface for debugging func (m *messageProcessor) String() string {
//func (m *messageProcessor) String() string { return m.bindingsCbs.String()
// return m.bindingsCbs.String() }
//}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment