Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
fcf8c1c9
Commit
fcf8c1c9
authored
3 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
add bindings
parent
8b6c37a8
No related branches found
No related tags found
3 merge requests
!510
Release
,
!226
WIP: Api2.0
,
!207
WIP: Client Restructure
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bindings/connect.go
+52
-8
52 additions, 8 deletions
bindings/connect.go
bindings/connectionTracker.go
+0
-8
0 additions, 8 deletions
bindings/connectionTracker.go
bindings/restlike.go
+7
-0
7 additions, 0 deletions
bindings/restlike.go
with
59 additions
and
16 deletions
bindings/connect.go
+
52
−
8
View file @
fcf8c1c9
...
@@ -5,28 +5,31 @@ import (
...
@@ -5,28 +5,31 @@ import (
"gitlab.com/elixxir/client/catalog"
"gitlab.com/elixxir/client/catalog"
"gitlab.com/elixxir/client/connect"
"gitlab.com/elixxir/client/connect"
e2e2
"gitlab.com/elixxir/client/e2e"
e2e2
"gitlab.com/elixxir/client/e2e"
contact2
"gitlab.com/elixxir/crypto/contact"
"gitlab.com/elixxir/client/e2e/ratchet/partner"
"gitlab.com/elixxir/crypto/e2e"
"gitlab.com/elixxir/client/e2e/receive"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/elixxir/crypto/contact"
"time"
)
)
//connection tracker singleton, used to track connections so they can be
//connection tracker singleton, used to track connections so they can be
//referenced by id back over the bindings
//referenced by id back over the bindings
var
connectionTrackerSingleton
=
&
connectionTracker
{
var
connectionTrackerSingleton
=
&
connectionTracker
{
connections
:
make
(
map
[
int
]
Connection
),
connections
:
make
(
map
[
int
]
*
Connection
),
count
:
0
,
count
:
0
,
}
}
//
type
Connection
struct
{
type
Connection
struct
{
connection
connect
.
Connection
connection
connect
.
Authenticated
Connection
id
int
id
int
}
}
// Connect blocks until it connects to the remote
// Connect performs auth key negotiation with the given recipient,
// and returns a Connection object for the newly-created partner.Manager
// This function is to be used sender-side and will block until the
// partner.Manager is confirmed.
func
(
c
*
Client
)
Connect
(
recipientContact
[]
byte
,
myIdentity
[]
byte
)
(
func
(
c
*
Client
)
Connect
(
recipientContact
[]
byte
,
myIdentity
[]
byte
)
(
*
Connection
,
error
)
{
*
Connection
,
error
)
{
cont
,
err
:=
contact
2
.
Unmarshal
(
recipientContact
)
cont
,
err
:=
contact
.
Unmarshal
(
recipientContact
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -45,12 +48,32 @@ func (c *Client) Connect(recipientContact []byte, myIdentity []byte) (
...
@@ -45,12 +48,32 @@ func (c *Client) Connect(recipientContact []byte, myIdentity []byte) (
return
connectionTrackerSingleton
.
make
(
connection
),
nil
return
connectionTrackerSingleton
.
make
(
connection
),
nil
}
}
// ConnectWithAuthentication is called by the client, ie the one establishing
// connection with the server. Once a connect.Connection has been established
// with the server and then authenticate their identity to the server.
func
(
c
*
Client
)
ConnectWithAuthentication
(
recipientContact
[]
byte
,
myIdentity
[]
byte
)
(
*
Connection
,
error
)
{
cont
,
err
:=
contact
.
Unmarshal
(
recipientContact
)
if
err
!=
nil
{
return
nil
,
err
}
myID
,
rsaPriv
,
salt
,
myDHPriv
,
err
:=
unmarshalIdentity
(
myIdentity
)
if
err
!=
nil
{
return
nil
,
err
}
connection
,
err
:=
connect
.
ConnectWithAuthentication
(
cont
,
myID
,
salt
,
rsaPriv
,
myDHPriv
,
c
.
api
.
GetRng
(),
c
.
api
.
GetStorage
()
.
GetE2EGroup
(),
c
.
api
.
GetCmix
(),
connect
.
GetDefaultParams
())
return
connectionTrackerSingleton
.
make
(
connection
),
nil
}
//
type
E2ESendReport
struct
{
type
E2ESendReport
struct
{
roundsList
roundsList
MessageID
[]
byte
MessageID
[]
byte
Timestamp
int64
Timestamp
int64
}
}
// SendE2E is a wrapper for sending specifically to the Connection's partner.Manager
func
(
c
*
Connection
)
SendE2E
(
mt
int
,
payload
[]
byte
)
([]
byte
,
error
)
{
func
(
c
*
Connection
)
SendE2E
(
mt
int
,
payload
[]
byte
)
([]
byte
,
error
)
{
rounds
,
mid
,
ts
,
err
:=
c
.
connection
.
SendE2E
(
catalog
.
MessageType
(
mt
),
payload
,
rounds
,
mid
,
ts
,
err
:=
c
.
connection
.
SendE2E
(
catalog
.
MessageType
(
mt
),
payload
,
e2e2
.
GetDefaultParams
())
e2e2
.
GetDefaultParams
())
...
@@ -68,3 +91,24 @@ func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) {
...
@@ -68,3 +91,24 @@ func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) {
return
json
.
Marshal
(
&
sr
)
return
json
.
Marshal
(
&
sr
)
}
}
// Close deletes this Connection's partner.Manager and releases resources
func
(
c
*
Connection
)
Close
()
{
c
.
Close
()
}
// GetPartner returns the partner.Manager for this Connection
func
(
c
*
Connection
)
GetPartner
()
partner
.
Manager
{
}
// RegisterListener is used for E2E reception
// and allows for reading data sent from the partner.Manager
func
(
c
*
Connection
)
RegisterListener
(
messageType
int
,
newListener
receive
.
Listener
)
receive
.
ListenerID
{
}
// Unregister listener for E2E reception
func
(
c
*
Connection
)
Unregister
(
listenerID
receive
.
ListenerID
)
{
}
This diff is collapsed.
Click to expand it.
bindings/connectionTracker.go
+
0
−
8
View file @
fcf8c1c9
...
@@ -6,14 +6,6 @@ import (
...
@@ -6,14 +6,6 @@ import (
"sync"
"sync"
)
)
package
bindings
import
(
"github.com/pkg/errors"
"gitlab.com/elixxir/client/api"
"sync"
)
// connectionTracker is a singleton used to keep track of extant clients, allowing
// connectionTracker is a singleton used to keep track of extant clients, allowing
// for race condition free passing over the bindings
// for race condition free passing over the bindings
...
...
This diff is collapsed.
Click to expand it.
bindings/restlike.go
0 → 100644
+
7
−
0
View file @
fcf8c1c9
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2022 Privategrity Corporation /
// /
// All rights reserved. /
////////////////////////////////////////////////////////////////////////////////
package
bindings
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment