Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • Ace/Huawei
  • Anne/CI-Skip-WASM-Option
  • Anne/Gomobile-CI
  • XX-4004/GoUpdateFix
  • XX-4222-ratchet-unit-tests
  • XX-4223/BackupMultiLookup
  • XX-4262/HostPoolRotation
  • XX-4296_dynamic_decoy_message_scheduler
  • XX-4309/HttpsTesting
  • XX-4363/GroupChat
  • XX-4441
  • XX-4507/dotnet
  • XX-4546/RemoteKvClient
  • XX-4601/HavenInvites
  • XX-4602/SilentMessageType
  • XX-4673/AdminKeySync
  • XX-4677/NewChanManagerMobile
  • XX-4681/RestlikeModifications
  • XX-4682/Files
  • XX-4689/DmSync
  • XX-4707/tagDiskJson
  • XX-4719/announcementChannels
  • anne-ipad-test
  • anne-ipad-test2
  • anne/test
  • debugNotifID
  • duplicatePrefix
  • fast-registration-noSubtleCrypto
  • feature/ctidh
  • finalizedUICallbacks
  • hotfix/FrontEndDebug
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • hotfix/emptyauth
  • hotfix/emptyauthmaster
  • hotfix/hostPool-networkError
  • hotfix/hostpoolSelection
  • hotfix/jsNtp
  • hotfix/localCB
  • hotfix/notifylockup
  • hotifx/WaitThatsIllegal
  • httpsSupport
  • jonah/noob-channel
  • jonah/redoBatchPickupRefactor
  • master
  • mm/notification_override
  • mobile_master
  • notificationsPackage
  • pauseRegistration
  • project/HavenNotifications
  • project/httpsSupport
  • projects/crust_RELEASE
  • release
  • sydney-ipad-test3
  • syncNodes
  • testRSAVerif
  • testRSAVerify
  • testing/hostpoolReconnect
  • tls-websockets
  • whatBreaksIt
  • working-release
  • xx-4283/fast-registration
  • xx-4599/improveBatchPickup
  • xx-4698/notification-retry
  • xx-4717/logLevel
  • v0.1.0
  • v0.2.0
  • v1.0.0
  • v1.0.0-VerDiffTest
  • v1.1.0
  • v1.1.1
  • v1.2.0
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v2.0.0
  • v2.10.0
  • v2.3.0
  • v2.5.0
  • v2.8.0
  • v3.2.0
  • v4.0.0
  • v4.1.0
  • v4.2.0
  • v4.3.0
  • v4.3.1
  • v4.3.11
  • v4.3.2
  • v4.3.3
  • v4.3.4
  • v4.3.5
  • v4.3.6
  • v4.3.7
  • v4.3.8
  • v4.4.4
  • v4.5.0
  • v4.6.1
  • v4.6.3
  • v4.7.1
  • v4.7.2
  • v4.7.3
  • v4.7.4
  • v4.7.5
103 results

Target

Select target project
  • elixxir/client
  • mirabel/client
2 results
Select Git revision
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • Ace/Huawei
  • Anne/CI-Skip-WASM-Option
  • Anne/Gomobile-CI
  • XX-4004/GoUpdateFix
  • XX-4222-ratchet-unit-tests
  • XX-4223/BackupMultiLookup
  • XX-4262/HostPoolRotation
  • XX-4296_dynamic_decoy_message_scheduler
  • XX-4309/HttpsTesting
  • XX-4363/GroupChat
  • XX-4441
  • XX-4507/dotnet
  • XX-4546/RemoteKvClient
  • XX-4601/HavenInvites
  • XX-4602/SilentMessageType
  • XX-4673/AdminKeySync
  • XX-4677/NewChanManagerMobile
  • XX-4681/RestlikeModifications
  • XX-4682/Files
  • XX-4689/DmSync
  • XX-4707/tagDiskJson
  • XX-4719/announcementChannels
  • anne-ipad-test
  • anne-ipad-test2
  • anne/test
  • debugNotifID
  • duplicatePrefix
  • fast-registration-noSubtleCrypto
  • feature/ctidh
  • finalizedUICallbacks
  • hotfix/FrontEndDebug
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • hotfix/emptyauth
  • hotfix/emptyauthmaster
  • hotfix/hostPool-networkError
  • hotfix/hostpoolSelection
  • hotfix/jsNtp
  • hotfix/localCB
  • hotfix/notifylockup
  • hotifx/WaitThatsIllegal
  • httpsSupport
  • jonah/noob-channel
  • jonah/redoBatchPickupRefactor
  • master
  • mm/notification_override
  • mobile_master
  • notificationsPackage
  • pauseRegistration
  • project/HavenNotifications
  • project/httpsSupport
  • projects/crust_RELEASE
  • release
  • sydney-ipad-test3
  • syncNodes
  • testRSAVerif
  • testRSAVerify
  • testing/hostpoolReconnect
  • tls-websockets
  • whatBreaksIt
  • working-release
  • xx-4283/fast-registration
  • xx-4599/improveBatchPickup
  • xx-4698/notification-retry
  • xx-4717/logLevel
  • v0.1.0
  • v0.2.0
  • v1.0.0
  • v1.0.0-VerDiffTest
  • v1.1.0
  • v1.1.1
  • v1.2.0
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v2.0.0
  • v2.10.0
  • v2.3.0
  • v2.5.0
  • v2.8.0
  • v3.2.0
  • v4.0.0
  • v4.1.0
  • v4.2.0
  • v4.3.0
  • v4.3.1
  • v4.3.11
  • v4.3.2
  • v4.3.3
  • v4.3.4
  • v4.3.5
  • v4.3.6
  • v4.3.7
  • v4.3.8
  • v4.4.4
  • v4.5.0
  • v4.6.1
  • v4.6.3
  • v4.7.1
  • v4.7.2
  • v4.7.3
  • v4.7.4
  • v4.7.5
103 results
Show changes

Commits on Source 4

Showing with 306 additions and 191 deletions
......@@ -34,7 +34,6 @@ func (_ *AuthenticatedConnection) IsAuthenticated() bool {
// ConnectWithAuthentication is called by the client (i.e., the one establishing
// connection with the server). Once a connect.Connection has been established
// with the server, it then authenticates their identity to the server.
// accepts a marshalled ReceptionIdentity and contact.Contact object
func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact,
e2eParamsJSON []byte) (*AuthenticatedConnection, error) {
if len(e2eParamsJSON) == 0 {
......
......@@ -55,7 +55,7 @@ type UpdateBackupFunc interface {
// backup. Users of this function should delete the storage directory on error.
// Users of this function should call LoadCmix as normal once this call succeeds.
//
// Params
// Parameters:
// - ndfJSON - JSON of the NDF.
// - storageDir - directory for the storage files.
// - sessionPassword - password to decrypt the data in the storageDir.
......@@ -92,10 +92,11 @@ func NewCmixFromBackup(ndfJSON, storageDir, backupPassphrase string,
// InitializeBackup creates a bindings-layer Backup object.
//
// Params
// Parameters:
// - e2eID - ID of the E2e object in the e2e tracker.
// - udID - ID of the UserDiscovery object in the ud tracker.
// - backupPassPhrase - backup passphrase provided by the user. Used to decrypt backup.
// - backupPassPhrase - backup passphrase provided by the user. Used to decrypt
// backup.
// - cb - the callback to be called when a backup is triggered.
func InitializeBackup(e2eID, udID int, backupPassPhrase string,
cb UpdateBackupFunc) (*Backup, error) {
......@@ -129,7 +130,7 @@ func InitializeBackup(e2eID, udID int, backupPassPhrase string,
// To start the backup for the first time or to use a new password, use
// InitializeBackup.
//
// Params
// Parameters:
// - e2eID - ID of the E2e object in the e2e tracker.
// - udID - ID of the UserDiscovery object in the ud tracker.
// - cb - the callback to be called when a backup is triggered.
......
......@@ -19,15 +19,18 @@ import (
"gitlab.com/xx_network/primitives/id/ephemeral"
)
// Channel is a bindings-level struct encapsulating the broadcast.Channel client object.
// Channel is a bindings-level struct encapsulating the broadcast.Channel client
// object.
type Channel struct {
ch broadcast.Channel
}
// ChannelDef is the bindings representation of an elixxir/crypto broadcast.Channel object.
// ChannelDef is the bindings representation of an elixxir/crypto
// broadcast.Channel object.
//
// Example JSON:
// {"Name": "My broadcast channel",
// {
// "Name": "My broadcast channel",
// "Description": "A broadcast channel for me to test things",
// "Salt": "gpUqW7N22sffMXsvPLE7BA==",
// "PubKey": "LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0="
......@@ -51,7 +54,8 @@ type BroadcastMessage struct {
Payload []byte
}
// BroadcastReport is the bindings representation of the info on how a broadcast message was sent
// BroadcastReport is the bindings representation of the info on how a broadcast
// message was sent
//
// Example JSON:
// {"RoundID":42,
......@@ -72,7 +76,8 @@ type BroadcastListener interface {
Callback([]byte, error)
}
// NewBroadcastChannel creates a bindings-layer broadcast channel & starts listening for new messages
// NewBroadcastChannel creates a bindings-layer broadcast channel and starts
// listening for new messages.
//
// Parameters:
// - cmixId - internal ID of cmix
......@@ -112,8 +117,8 @@ func NewBroadcastChannel(cmixId int, channelDefinition []byte) (*Channel, error)
return &Channel{ch: ch}, nil
}
// Listen registers a BroadcastListener for a given method.
// This allows users to handle incoming broadcast messages.
// Listen registers a BroadcastListener for a given method. This allows users to
// handle incoming broadcast messages.
//
// Parameters:
// - l - BroadcastListener object
......@@ -139,7 +144,8 @@ func (c *Channel) Listen(l BroadcastListener, method int) error {
//
// Returns:
// - []byte - the JSON marshalled bytes of the BroadcastReport object, which
// can be passed into WaitForRoundResult to see if the broadcast succeeded.
// can be passed into Cmix.WaitForRoundResult to see if the broadcast
// succeeded.
func (c *Channel) Broadcast(payload []byte) ([]byte, error) {
rid, eid, err := c.ch.Broadcast(payload, cmix.GetDefaultCMIXParams())
if err != nil {
......@@ -172,17 +178,20 @@ func (c *Channel) BroadcastAsymmetric(payload, pk []byte) ([]byte, error) {
})
}
// MaxPayloadSize returns the maximum possible payload size which can be broadcast.
// MaxPayloadSize returns the maximum possible payload size which can be
// broadcast.
func (c *Channel) MaxPayloadSize() int {
return c.ch.MaxPayloadSize()
}
// MaxAsymmetricPayloadSize returns the maximum possible payload size which can be broadcast.
// MaxAsymmetricPayloadSize returns the maximum possible payload size which can
// be broadcast.
func (c *Channel) MaxAsymmetricPayloadSize() int {
return c.ch.MaxAsymmetricPayloadSize()
}
// Get returns the result of calling json.Marshal on a ChannelDef based on the underlying crypto broadcast.Channel.
// Get returns the result of calling json.Marshal on a ChannelDef based on the
// underlying crypto broadcast.Channel.
func (c *Channel) Get() ([]byte, error) {
def := c.ch.Get()
return json.Marshal(&ChannelDef{
......
......@@ -48,7 +48,7 @@ func (c *Connection) GetId() int {
// Parameters:
// - e2eId - ID of the E2E object in the e2e tracker
// - recipientContact - marshalled contact.Contact object
// - myIdentity - marshalled ReceptionIdentity object
// - e2eParamsJSON - JSON marshalled byte of xxdk.E2EParams object
func (c *Cmix) Connect(e2eId int, recipientContact, e2eParamsJSON []byte) (
*Connection, error) {
if len(e2eParamsJSON) == 0 {
......@@ -83,7 +83,7 @@ func (c *Cmix) Connect(e2eId int, recipientContact, e2eParamsJSON []byte) (
//
// Returns:
// - []byte - the JSON marshalled bytes of the E2ESendReport object, which can
// be passed into WaitForRoundResult to see if the send succeeded.
// be passed into Cmix.WaitForRoundResult to see if the send succeeded.
func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) {
rounds, mid, ts, err := c.connection.SendE2E(catalog.MessageType(mt), payload,
c.params.Base)
......
......@@ -70,19 +70,21 @@ type MessageDeliveryCallback interface {
EventCallback(delivered, timedOut bool, roundResults []byte)
}
// WaitForRoundResult allows the caller to get notified if the rounds a
// message was sent in successfully completed. Under the hood, this uses an API
// that uses the internal round data, network historical round lookup, and
// waiting on network events to determine what has (or will) occur.
//
// The callbacks will return at timeoutMS if no state update occurs.
// WaitForRoundResult allows the caller to get notified if the rounds a message
// was sent in successfully completed. Under the hood, this uses an API that
// uses the internal round data, network historical round lookup, and waiting on
// network events to determine what has (or will) occur.
//
// This function takes the marshaled send report to ensure a memory leak does
// not occur as a result of both sides of the bindings holding a reference to
// the same pointer.
//
// roundList is a JSON marshalled RoundsList or any JSON marshalled send report
// that inherits a RoundsList object.
// Parameters:
// - roundList - JSON marshalled bytes of RoundsList or JSON of any send report
// that inherits a [bindings.RoundsList] object
// - mdc - callback that adheres to the MessageDeliveryCallback interface
// - timeoutMS - timeout when the callback will return if no state update
// occurs, in milliseconds
func (c *Cmix) WaitForRoundResult(
roundList []byte, mdc MessageDeliveryCallback, timeoutMS int) error {
jww.INFO.Printf("WaitForRoundResult(%s, _, %d)", roundList, timeoutMS)
......
......@@ -20,21 +20,21 @@ type DummyTraffic struct {
}
// NewDummyTrafficManager creates a DummyTraffic manager and initialises the
// dummy traffic sending thread. Note that the manager does not start sending dummy
// traffic until `True` is passed into DummyTraffic.SetStatus. The time duration
// between each sending operation and the amount of messages sent each interval
// are randomly generated values with bounds defined by the
// given parameters below.
// dummy traffic sending thread. Note that the manager does not start sending
// dummy traffic until true is passed into DummyTraffic.SetStatus. The time
// duration between each sending operation and the amount of messages sent each
// interval are randomly generated values with bounds defined by the given
// parameters below.
//
// Params:
// Parameters:
// - cmixId - a Cmix object ID in the tracker.
// - maxNumMessages - the upper bound of the random number of messages sent
// each sending cycle.
// - avgSendDeltaMS - the average duration, in milliseconds, to wait
// between sends.
// - randomRangeMS - the upper bound of the interval between sending cycles,
// in milliseconds. Sends occur every avgSendDeltaMS +/- a random duration
// with an upper bound of randomRangeMS.
// - avgSendDeltaMS - the average duration, in milliseconds, to wait between
// sends.
// - randomRangeMS - the upper bound of the interval between sending cycles, in
// milliseconds. Sends occur every avgSendDeltaMS +/- a random duration with
// an upper bound of randomRangeMS.
func NewDummyTrafficManager(cmixId, maxNumMessages, avgSendDeltaMS,
randomRangeMS int) (*DummyTraffic, error) {
......@@ -53,33 +53,34 @@ func NewDummyTrafficManager(cmixId, maxNumMessages, avgSendDeltaMS,
return &DummyTraffic{m}, net.api.AddService(m.StartDummyTraffic)
}
// SetStatus sets the state of the DummyTraffic manager's send thread by passing in
// a boolean parameter. There may be a small delay in between this call
// and the status of the sending thread to change accordingly. For example,
// passing False into this call while the sending thread is currently sending messages
// will not cancel nor halt the sending operation, but will pause the thread once that
// operation has completed.
// SetStatus sets the state of the DummyTraffic manager's send thread by passing
// in a boolean parameter. There may be a small delay in between this call and
// the status of the sending thread to change accordingly. For example, passing
// false into this call while the sending thread is currently sending messages
// will not cancel nor halt the sending operation, but will pause the thread
// once that operation has completed.
//
// Parameters:
// - status - Input should be true if you want to send dummy messages and false
// if you want to pause dummy messages.
//
// Params:
// - boolean - Input should be true if you want to send dummy messages.
// Input should be false if you want to pause dummy messages.
// Returns:
// - error - if the DummyTraffic.SetStatus is called too frequently, causing the
// internal status channel to fill.
// - error - if the DummyTraffic.SetStatus is called too frequently, causing
// the internal status channel to fill.
func (dt *DummyTraffic) SetStatus(status bool) error {
return dt.m.SetStatus(status)
}
// GetStatus returns the current state of the DummyTraffic manager's sending thread.
// Note that this function does not return the status set by the most recent call to
// SetStatus. Instead, this call returns the current status of the sending thread.
// This is due to the small delay that may occur between calling SetStatus and the
// sending thread taking into effect that status change.
// GetStatus returns the current state of the DummyTraffic manager's sending
// thread. Note that this function does not return the status set by the most
// recent call to SetStatus. Instead, this call returns the current status of
// the sending thread. This is due to the small delay that may occur between
// calling SetStatus and the sending thread taking into effect that status
// change.
//
// Returns:
// - boolean - Returns true if sending thread is sending dummy messages.
// Returns false if sending thread is paused/stopped and is
// not sending dummy messages.
// - bool - Returns true if sending thread is sending dummy messages and false
// if sending thread is paused/stopped and is not sending dummy messages.
func (dt *DummyTraffic) GetStatus() bool {
return dt.m.GetStatus()
}
......@@ -171,8 +171,7 @@ func (e *E2e) DeleteSentRequests() error {
return e.api.GetAuth().DeleteSentRequests()
}
// DeleteReceiveRequests clears all received requests from auth
// storage.
// DeleteReceiveRequests clears all received requests from auth storage.
func (e *E2e) DeleteReceiveRequests() error {
return e.api.GetAuth().DeleteReceiveRequests()
}
......
......@@ -24,9 +24,11 @@ import (
// SendE2E.
//
// Example E2ESendReport:
// {"Rounds":[1,5,9],
// {
// "Rounds":[1,5,9],
// "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=",
// "Timestamp":1653582683183384000}
// "Timestamp":1653582683183384000
// }
type E2ESendReport struct {
RoundsList
MessageID []byte
......@@ -117,7 +119,7 @@ func (e *E2e) RemoveService(tag string) error {
//
// Returns:
// - []byte - the JSON marshalled bytes of the E2ESendReport object, which can
// be passed into WaitForRoundResult to see if the send succeeded.
// be passed into Cmix.WaitForRoundResult to see if the send succeeded.
func (e *E2e) SendE2E(messageType int, recipientId, payload,
e2eParams []byte) ([]byte, error) {
// Note that specifically these are the Base params from xxdk.E2EParams
......@@ -166,11 +168,9 @@ func (e *E2e) AddService(tag string, processor Processor) error {
// - messageType - message type from the sender you want to listen for.
// - newListener: A provider for a callback to hear a message.
// Do not pass nil to this.
func (e *E2e) RegisterListener(senderID []byte,
messageType int,
newListener Listener) error {
jww.INFO.Printf("RegisterListener(%v, %d)", senderID,
messageType)
func (e *E2e) RegisterListener(
senderID []byte, messageType int, newListener Listener) error {
jww.INFO.Printf("RegisterListener(%v, %d)", senderID, messageType)
// Convert senderID to id.Id object
var uid *id.ID
......
......@@ -46,14 +46,14 @@ const (
UnrecognizedMessage = UnrecognizedCode + "Unrecognized error from XX backend, please report"
)
// CreateUserFriendlyErrorMessage will convert the passed in error string
// to an error string that is user-friendly if a substring match is
// found to a common error. Common errors is a map which can be updated
// using UpdateCommonErrors. If the error is not common, some simple parsing
// is done on the error message to make it more user-accessible, removing
// backend specific jargon.
// CreateUserFriendlyErrorMessage will convert the passed in error string to an
// error string that is user-friendly if a substring match is found to a
// common error. Common errors is a map that can be updated using
// UpdateCommonErrors. If the error is not common, some simple parsing is done
// on the error message to make it more user-accessible, removing backend
// specific jargon.
//
// Parameters
// Parameters:
// - errStr - an error returned from the backend.
//
// Returns
......@@ -97,11 +97,13 @@ func CreateUserFriendlyErrorMessage(errStr string) string {
return fmt.Sprintf("%s: %v", UnrecognizedCode, errStr)
}
// UpdateCommonErrors updates the internal error mapping DB. This internal database
// maps errors returned from the backend to user-friendly error messages.
// UpdateCommonErrors updates the internal error mapping database. This internal
// database maps errors returned from the backend to user-friendly error
// messages.
//
// Parameters
// Parameters:
// - jsonFile - contents of a JSON file whose format conforms to the example below.
//
// Example Input:
// {
// "Failed to Unmarshal Conversation": "Could not retrieve conversation",
......
......@@ -179,7 +179,6 @@ func InitFileTransfer(e2eID int, receiveFileCallback ReceiveFileCallback,
// Parameters:
// - payload - JSON marshalled FileSend
// - recipientID - marshalled recipient id.ID
// - paramsJSON - JSON marshalled e2e.Params
// - retry - number of retries allowed
// - callback - callback that reports file sending progress
// - period - duration to wait between progress callbacks triggering
......
......@@ -41,8 +41,8 @@ import (
// can be signaled to check all recent messages that could be decoded. It
// uses a message store on disk for persistence.
// - Critical Messages (/network/message/critical.go)
// ensures all protocol layer mandatory messages are sent. It uses a
// message store on disk for persistence.
// ensures all protocol layer mandatory messages are sent. It uses a message
// store on disk for persistence.
// - KeyExchange Trigger (/keyExchange/trigger.go)
// responds to sent rekeys and executes them.
// - KeyExchange Confirm (/keyExchange/confirm.go)
......@@ -58,7 +58,7 @@ func (c *Cmix) StartNetworkFollower(timeoutMS int) error {
// an error if the follower is in the wrong state to stop or if it fails to stop
// it.
//
// if the network follower is running and this fails, the Cmix object will
// If the network follower is running and this fails, the Cmix object will
// most likely be in an unrecoverable state and need to be trashed.
func (c *Cmix) StopNetworkFollower() error {
if err := c.api.StopNetworkFollower(); err != nil {
......@@ -84,11 +84,9 @@ func (c *Cmix) WaitForNetwork(timeoutMS int) bool {
// NetworkFollowerStatus gets the state of the network follower. It returns a
// status with the following values:
//
// Status:
// - Stopped - 0
// - Running - 2000
// - Stopping - 3000
// Stopped - 0
// Running - 2000
// Stopping - 3000
func (c *Cmix) NetworkFollowerStatus() int {
return int(c.api.NetworkFollowerStatus())
}
......@@ -103,10 +101,11 @@ type NodeRegistrationReport struct {
// GetNodeRegistrationStatus returns the current state of node registration.
//
// Returns:
// - []bye - A marshalled NodeRegistrationReport containing the number of
// nodes the user is registered with and the number of nodes present in the NDF.
// - An error if it cannot get the node registration status. The most likely cause
// is that the network is unhealthy.
// - []byte - A marshalled NodeRegistrationReport containing the number of
// nodes the user is registered with and the number of nodes present in the
// NDF.
// - An error if it cannot get the node registration status. The most likely
// cause is that the network is unhealthy.
func (c *Cmix) GetNodeRegistrationStatus() ([]byte, error) {
numNodesRegistered, numNodes, err := c.api.GetNodeRegistrationStatus()
if err != nil {
......
......@@ -129,16 +129,16 @@ func NewGroupChat(e2eID int,
// IDs of members the user wants to add to the group.
// - message - the initial message sent to all members in the group. This is an
// optional parameter and may be nil.
// - tag - the name of the group decided by the creator. This is an optional
// - name - the name of the group decided by the creator. This is an optional
// parameter and may be nil. If nil the group will be assigned the default
// name.
//
// Returns:
// - []byte - the JSON marshalled bytes of the GroupReport object, which can be
// passed into WaitForRoundResult to see if the group request message send
// succeeded.
func (g *GroupChat) MakeGroup(membershipBytes []byte, message, name []byte) (
[]byte, error) {
// passed into Cmix.WaitForRoundResult to see if the group request message
// send succeeded.
func (g *GroupChat) MakeGroup(
membershipBytes, message, name []byte) ([]byte, error) {
// Unmarshal membership list into a list of []*id.Id
var members []*id.ID
......@@ -246,17 +246,16 @@ func (g *GroupChat) LeaveGroup(groupId []byte) error {
// Send is the bindings-level function for sending to a group.
//
// Parameters:
// - groupId - the byte data representing a group ID.
// This can be pulled from a marshalled GroupReport.
// - groupId - the byte data representing a group ID. This can be pulled from
// marshalled GroupReport.
// - message - the message that the user wishes to send to the group.
// - tag - the tag associated with the message. This tag may be empty.
//
// Returns:
// - []byte - the JSON marshalled bytes of the GroupSendReport object, which
// can be passed into WaitForRoundResult to see if the group message send
// succeeded.
func (g *GroupChat) Send(groupId,
message []byte, tag string) ([]byte, error) {
// can be passed into Cmix.WaitForRoundResult to see if the group message
// send succeeded.
func (g *GroupChat) Send(groupId, message []byte, tag string) ([]byte, error) {
groupID, err := id.Unmarshal(groupId)
if err != nil {
return nil, errors.Errorf("Failed to unmarshal group ID: %+v", err)
......@@ -317,7 +316,7 @@ func (g *GroupChat) NumGroups() int {
}
////////////////////////////////////////////////////////////////////////////////
// Group Structure
// Group Structure //
////////////////////////////////////////////////////////////////////////////////
// Group structure contains the identifying and membership information of a
......@@ -332,12 +331,13 @@ func (g *Group) GetName() []byte {
return g.g.Name
}
// GetID return the 33-byte unique group ID. This represents the id.ID object
// GetID return the 33-byte unique group ID. This represents the id.ID object.
func (g *Group) GetID() []byte {
return g.g.ID.Bytes()
}
// GetTrackedID returns the tracked ID of the Group object. This is used by the backend tracker.
// GetTrackedID returns the tracked ID of the Group object. This is used by the
// backend tracker.
func (g *Group) GetTrackedID() int {
return g.id
}
......@@ -375,9 +375,9 @@ func (g *Group) Serialize() []byte {
return g.g.Serialize()
}
//////////////////////////////////////////////////////////////////////////////////
// Callbacks
//////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Callbacks //
////////////////////////////////////////////////////////////////////////////////
// GroupRequest is a bindings-layer interface that handles a group reception.
//
......
......@@ -10,7 +10,6 @@
package bindings
import (
"fmt"
"log"
"github.com/pkg/errors"
......@@ -34,7 +33,7 @@ import (
// The default log level without updates is INFO.
func LogLevel(level int) error {
if level < 0 || level > 6 {
return errors.New(fmt.Sprintf("log level is not valid: log level: %d", level))
return errors.Errorf("log level is not valid: log level: %d", level)
}
threshold := jww.Threshold(level)
......
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
////////////////////////////////////////////////////////////////////////////////
package bindings
// FIXME: This is the old NotificationsForMe code that needs to be fixed
/*
type NotificationForMeReport struct {
ForMe bool
Type string
Source []byte
}
type ManyNotificationForMeReport struct {
Many []*NotificationForMeReport
}
// NotificationsForMe Check if a notification received is for me
// It returns a NotificationForMeReport which contains a ForMe bool stating if it is for the caller,
// a Type, and a source. These are as follows:
// TYPE SOURCE DESCRIPTION
// "default" recipient user ID A message with no association
// "request" sender user ID A channel request has been received
// "reset" sender user ID A channel reset has been received
// "confirm" sender user ID A channel request has been accepted
// "silent" sender user ID A message which should not be notified on
// "e2e" sender user ID reception of an E2E message
// "group" group ID reception of a group chat message
// "endFT" sender user ID Last message sent confirming end of file transfer
// "groupRQ" sender user ID Request from sender to join a group chat
func NotificationsForMe(notifCSV, preimages string) (*ManyNotificationForMeReport, error) {
// Handle deserialization of preimages
var preimageList []edge.Preimage
if err := json.Unmarshal([]byte(preimages), &preimageList); err != nil {
return nil, errors.WithMessagef(err, "Failed to unmarshal the " +
"preimages list, cannot check if notification is for me")
}
list, err := notifications.DecodeNotificationsCSV(notifCSV)
if err != nil {
return nil, err
}
notifList := make([]*NotificationForMeReport, len(list))
for i, notifData := range list {
notifList[i] = &NotificationForMeReport{
ForMe: false,
Type: "",
Source: nil,
}
// check if any preimages match with the passed in data
for _, preimage := range preimageList {
if fingerprint.CheckIdentityFpFromMessageHash(notifData.IdentityFP, notifData.MessageHash, preimage.Data) {
notifList[i] = &NotificationForMeReport{
ForMe: true,
Type: preimage.Type,
Source: preimage.Source,
}
break
}
}
}
return &ManyNotificationForMeReport{notifList}, nil
}*/
// RegisterForNotifications allows a client to register for push notifications.
// The token is a firebase messaging token.
//
// Parameters:
// - e2eId - ID of the E2E object in the E2E tracker
func RegisterForNotifications(e2eId int, token string) error {
user, err := e2eTrackerSingleton.get(e2eId)
if err != nil {
return err
}
return user.api.RegisterForNotifications(token)
}
// UnregisterForNotifications turns off notifications for this client.
//
// Parameters:
// - e2eId - ID of the E2E object in the E2E tracker
func UnregisterForNotifications(e2eId int) error {
user, err := e2eTrackerSingleton.get(e2eId)
if err != nil {
return err
}
return user.api.UnregisterForNotifications()
}
......@@ -66,8 +66,8 @@ func GetDefaultSingleUseParams() []byte {
}
// GetDefaultE2eFileTransferParams returns a JSON serialized object with all the
// e2e file transfer parameters and their default values. Call this function and modify
// the JSON to change single use settings.
// E2E file transfer parameters and their default values. Call this function and
// modify the JSON to change single use settings.
func GetDefaultE2eFileTransferParams() []byte {
defaultParams := e2eFileTransfer.DefaultParams()
data, err := defaultParams.MarshalJSON()
......
......@@ -107,7 +107,7 @@ func RestlikeRequest(
//
// Returns:
// - []byte - JSON marshalled RestlikeMessage
func RestlikeRequestAuth(cmixId int, authConnectionID int, request,
func RestlikeRequestAuth(cmixId, authConnectionID int, request,
e2eParamsJSON []byte) ([]byte, error) {
if len(e2eParamsJSON) == 0 {
jww.WARN.Printf("restlike params unspecified, using defaults")
......
......@@ -68,8 +68,8 @@ func TransmitSingleUse(e2eID int, recipient []byte, tag string, payload,
return json.Marshal(sr)
}
// Listen starts a single-use listener on a given tag using the passed in e2e object
// and SingleUseCallback func.
// Listen starts a single-use listener on a given tag using the passed in E2e
// object and SingleUseCallback func.
//
// Parameters:
// - e2eID - ID of the e2e object in the tracker
......@@ -154,7 +154,8 @@ type SingleUseCallbackReport struct {
// Function Types //
////////////////////////////////////////////////////////////////////////////////
// Stopper is a public interface returned by Listen, allowing users to stop the registered listener.
// Stopper is a public interface returned by Listen, allowing users to stop the
// registered listener.
type Stopper interface {
Stop()
}
......@@ -164,8 +165,8 @@ type Stopper interface {
//
// Parameters:
// - callbackReport - the JSON marshalled bytes of the SingleUseCallbackReport
// object, which can be passed into WaitForRoundResult to see if the send
// succeeded.
// object, which can be passed into Cmix.WaitForRoundResult to see if the
// send succeeded.
type SingleUseCallback interface {
Callback(callbackReport []byte, err error)
}
......@@ -175,8 +176,8 @@ type SingleUseCallback interface {
//
// Parameters:
// - callbackReport - the JSON marshalled bytes of the SingleUseResponseReport
// object, which can be passed into WaitForRoundResult to see if the send
// succeeded.
// object, which can be passed into Cmix.WaitForRoundResult to see if the
// send succeeded.
type SingleUseResponse interface {
Callback(responseReport []byte, err error)
}
......
......@@ -105,34 +105,36 @@ type UdNetworkStatus interface {
// Manager functions //
////////////////////////////////////////////////////////////////////////////////
// NewOrLoadUd loads an existing Manager from storage or creates a
// new one if there is no extant storage information. Parameters need be provided
// to specify how to connect to the User Discovery service. These parameters may be used
// to contact either the UD server hosted by the xx network team or a custom
// third-party operated server. For the former, all the information may be pulled from the
// NDF using the bindings.
// NewOrLoadUd loads an existing Manager from storage or creates a new one if
// there is no extant storage information. Parameters need be provided to
// specify how to connect to the User Discovery service. These parameters may be
// used to contact either the UD server hosted by the xx network team or a
// custom third-party operated server. For the former, all the information may
// be pulled from the NDF using the bindings.
//
// Params
// - e2eID - e2e object ID in the tracker
// - follower - network follower func wrapped in UdNetworkStatus
// - username - the username the user wants to register with UD.
// If the user is already registered, this field may be blank
// - networkValidationSig is a signature provided by the network (i.e. the client registrar).
// This may be nil, however UD may return an error in some cases (e.g. in a production level
// environment).
// - cert is the TLS certificate for the UD server this call will connect with.
// You may use the UD server run by the xx network team by using E2e.GetUdCertFromNdf.
// - contactFile is the data within a marshalled contact.Contact. This represents the
// contact file of the server this call will connect with.
// You may use the UD server run by the xx network team by using E2e.GetUdContactFromNdf.
// - address is the IP address of the UD server this call will connect with.
// You may use the UD server run by the xx network team by using E2e.GetUdAddressFromNdf.
// - username - the username the user wants to register with UD. If the user is
// already registered, this field may be blank
// - registrationValidationSignature - a signature provided by the network
// (i.e., the client registrar). This may be nil; however, UD may return an
// error in some cases (e.g., in a production level environment).
// - cert - the TLS certificate for the UD server this call will connect with.
// You may use the UD server run by the xx network team by using
// E2e.GetUdCertFromNdf.
// - contactFile - the data within a marshalled contact.Contact. This
// represents the contact file of the server this call will connect with. You
// may use the UD server run by the xx network team by using
// E2e.GetUdContactFromNdf.
// - address - the IP address of the UD server this call will connect with. You
// may use the UD server run by the xx network team by using
// E2e.GetUdAddressFromNdf.
//
// Returns
// - A Manager object which is registered to the specified UD service.
func NewOrLoadUd(e2eID int, follower UdNetworkStatus,
username string, registrationValidationSignature,
cert, contactFile []byte, address string) (
func NewOrLoadUd(e2eID int, follower UdNetworkStatus, username string,
registrationValidationSignature, cert, contactFile []byte, address string) (
*UserDiscovery, error) {
// Get user from singleton
......@@ -167,15 +169,18 @@ func NewOrLoadUd(e2eID int, follower UdNetworkStatus,
// - follower - network follower func wrapped in UdNetworkStatus
// - emailFactJson - nullable JSON marshalled email [fact.Fact]
// - phoneFactJson - nullable JSON marshalled phone [fact.Fact]
// - cert is the TLS certificate for the UD server this call will connect with.
// You may use the UD server run by the xx network team by using E2e.GetUdCertFromNdf.
// - contactFile is the data within a marshalled contact.Contact. This represents the
// contact file of the server this call will connect with.
// You may use the UD server run by the xx network team by using E2e.GetUdContactFromNdf.
// - address is the IP address of the UD server this call will connect with.
// You may use the UD server run by the xx network team by using E2e.GetUdAddressFromNdf.
// - cert - the TLS certificate for the UD server this call will connect with.
// You may use the UD server run by the xx network team by using
// E2e.GetUdCertFromNdf.
// - contactFile - the data within a marshalled contact.Contact. This
// represents the contact file of the server this call will connect with. You
// may use the UD server run by the xx network team by using
// E2e.GetUdContactFromNdf.
// - address - the IP address of the UD server this call will connect with. You
// may use the UD server run by the xx network team by using
// E2e.GetUdAddressFromNdf.
func NewUdManagerFromBackup(e2eID int, follower UdNetworkStatus, emailFactJson,
phoneFactJson []byte, cert, contactFile []byte, address string) (*UserDiscovery, error) {
phoneFactJson, cert, contactFile []byte, address string) (*UserDiscovery, error) {
// Get user from singleton
user, err := e2eTrackerSingleton.get(e2eID)
......@@ -229,9 +234,9 @@ func (ud *UserDiscovery) GetContact() ([]byte, error) {
return ud.api.GetContact().Marshal(), nil
}
// ConfirmFact confirms a fact first registered via AddFact. The confirmation ID
// comes from AddFact while the code will come over the associated
// communications system.
// ConfirmFact confirms a fact first registered via SendRegisterFact. The
// confirmation ID comes from SendRegisterFact while the code will come over the
// associated communications system.
func (ud *UserDiscovery) ConfirmFact(confirmationID, code string) error {
return ud.api.ConfirmFact(confirmationID, code)
}
......@@ -309,13 +314,14 @@ type UdLookupCallback interface {
// Parameters:
// - e2eID - e2e object ID in the tracker
// - udContact - the marshalled bytes of the contact.Contact object
// - lookupId - the marshalled bytes of the id.ID object for the user
// that LookupUD will look up.
// - lookupId - the marshalled bytes of the id.ID object for the user that
// LookupUD will look up.
// - singleRequestParams - the JSON marshalled bytes of single.RequestParams
//
// Returns:
// - []byte - the JSON marshalled bytes of the SingleUseSendReport object,
// which can be passed into WaitForRoundResult to see if the send succeeded.
// which can be passed into Cmix.WaitForRoundResult to see if the send
// succeeded.
func LookupUD(e2eID int, udContact []byte, cb UdLookupCallback,
lookupId []byte, singleRequestParamsJSON []byte) ([]byte, error) {
......@@ -390,9 +396,10 @@ type UdSearchCallback interface {
//
// Returns:
// - []byte - the JSON marshalled bytes of the SingleUseSendReport object,
// which can be passed into WaitForRoundResult to see if the send succeeded.
// which can be passed into Cmix.WaitForRoundResult to see if the send
// succeeded.
func SearchUD(e2eID int, udContact []byte, cb UdSearchCallback,
factListJSON []byte, singleRequestParamsJSON []byte) ([]byte, error) {
factListJSON, singleRequestParamsJSON []byte) ([]byte, error) {
// Get user from singleton
user, err := e2eTrackerSingleton.get(e2eID)
......
......@@ -6,8 +6,8 @@ import (
pb "gitlab.com/elixxir/comms/mixmessages"
)
// ConfirmFact confirms a fact first registered via AddFact. The
// confirmation ID comes from AddFact while the code will come over the
// ConfirmFact confirms a fact first registered via SendRegisterFact. The
// confirmation ID comes from SendRegisterFact while the code will come over the
// associated communications system.
func (m *Manager) ConfirmFact(confirmationID, code string) error {
jww.INFO.Printf("ud.ConfirmFact(%s, %s)", confirmationID, code)
......
......@@ -375,7 +375,7 @@ func (c *Cmix) StartNetworkFollower(timeout time.Duration) error {
// an error if the follower is in the wrong state to stop or if it fails to stop
// it.
//
// if the network follower is running and this fails, the client object will
// If the network follower is running and this fails, the client object will
// most likely be in an unrecoverable state and need to be trashed.
func (c *Cmix) StopNetworkFollower() error {
jww.INFO.Printf("StopNetworkFollower()")
......