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
4f389b6b
Commit
4f389b6b
authored
3 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
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
!510
Release
,
!262
Add params options to bindings
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bindings/authenticatedConnection.go
+8
-3
8 additions, 3 deletions
bindings/authenticatedConnection.go
bindings/e2e.go
+24
-9
24 additions, 9 deletions
bindings/e2e.go
bindings/restlike.go
+20
-6
20 additions, 6 deletions
bindings/restlike.go
with
52 additions
and
18 deletions
bindings/authenticatedConnection.go
+
8
−
3
View file @
4f389b6b
...
...
@@ -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
(
p
aramsJSON
)
params
,
err
:=
parseE2EParams
(
e2eP
aramsJSON
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
bindings/e2e.go
+
24
−
9
View file @
4f389b6b
...
...
@@ -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
(
p
aramsJSON
)
params
,
err
:=
parseE2EParams
(
e2eP
aramsJSON
)
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
(
p
aramsJSON
)
params
,
err
:=
parseE2EParams
(
e2eP
aramsJSON
)
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
(
p
aramsJSON
)
params
,
err
:=
parseE2EParams
(
e2eP
aramsJSON
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
bindings/restlike.go
+
20
−
6
View file @
4f389b6b
...
...
@@ -10,7 +10,7 @@ package bindings
import
(
"encoding/json"
"git
la
b.com/
elixxir/client/e2e
"
jww
"git
hu
b.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
(
p
aramsJSON
)
params
,
err
:=
parseE2EParams
(
e2eP
aramsJSON
)
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
}
...
...
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