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
c4c63b43
Commit
c4c63b43
authored
2 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Add ephemeral initialization flag for connect CLI
parent
6855da0c
No related branches found
No related tags found
2 merge requests
!510
Release
,
!275
Implement connection CLI
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/connect.go
+27
-4
27 additions, 4 deletions
cmd/connect.go
cmd/flags.go
+1
-0
1 addition, 0 deletions
cmd/flags.go
cmd/init.go
+51
-0
51 additions, 0 deletions
cmd/init.go
with
79 additions
and
4 deletions
cmd/connect.go
+
27
−
4
View file @
c4c63b43
...
...
@@ -308,8 +308,16 @@ func insecureConnServer(forceLegacy bool, statePass []byte, statePath, regCode s
func
secureConnClient
(
forceLegacy
bool
,
statePass
[]
byte
,
statePath
,
regCode
string
,
cmixParams
xxdk
.
CMIXParams
,
e2eParams
xxdk
.
E2EParams
)
{
// Load client ------------------------------------------------------------------
messenger
:=
loadOrInitMessenger
(
forceLegacy
,
statePass
,
statePath
,
regCode
,
cmixParams
,
e2eParams
,
xxdk
.
DefaultAuthCallbacks
{})
var
messenger
*
xxdk
.
E2e
if
viper
.
GetBool
(
connectionEphemeralFlag
)
{
fmt
.
Println
(
"Loading ephemerally"
)
messenger
=
loadOrInitMessengerEphemeral
(
forceLegacy
,
statePass
,
statePath
,
regCode
,
cmixParams
,
e2eParams
,
xxdk
.
DefaultAuthCallbacks
{})
}
else
{
fmt
.
Println
(
"Loading non-ephemerally"
)
messenger
=
loadOrInitMessenger
(
forceLegacy
,
statePass
,
statePath
,
regCode
,
cmixParams
,
e2eParams
,
xxdk
.
DefaultAuthCallbacks
{})
}
// Start network threads---------------------------------------------------------
...
...
@@ -374,8 +382,16 @@ func insecureConnClient(forceLegacy bool, statePass []byte, statePath, regCode s
cmixParams
xxdk
.
CMIXParams
,
e2eParams
xxdk
.
E2EParams
)
{
// Load client ------------------------------------------------------------------
messenger
:=
loadOrInitMessenger
(
forceLegacy
,
statePass
,
statePath
,
regCode
,
cmixParams
,
e2eParams
,
xxdk
.
DefaultAuthCallbacks
{})
var
messenger
*
xxdk
.
E2e
if
viper
.
GetBool
(
connectionEphemeralFlag
)
{
fmt
.
Println
(
"Loading ephemerally"
)
messenger
=
loadOrInitMessengerEphemeral
(
forceLegacy
,
statePass
,
statePath
,
regCode
,
cmixParams
,
e2eParams
,
xxdk
.
DefaultAuthCallbacks
{})
}
else
{
fmt
.
Println
(
"Loading non-ephemerally"
)
messenger
=
loadOrInitMessenger
(
forceLegacy
,
statePass
,
statePath
,
regCode
,
cmixParams
,
e2eParams
,
xxdk
.
DefaultAuthCallbacks
{})
}
// Start network threads---------------------------------------------------------
...
...
@@ -554,5 +570,12 @@ func init() {
" will call the applicable authenticated counterpart"
)
bindFlagHelper
(
connectionAuthenticatedFlag
,
connectionCmd
)
connectionCmd
.
Flags
()
.
Bool
(
connectionEphemeralFlag
,
false
,
"This flag is available to both server and client. "
+
"This flag operates as a switch determining the initialization path."
+
"If present, the messenger will be initialized ephemerally. Without this flag, "
+
"the messenger will be initialized as stateful."
)
bindFlagHelper
(
connectionEphemeralFlag
,
connectionCmd
)
rootCmd
.
AddCommand
(
connectionCmd
)
}
This diff is collapsed.
Click to expand it.
cmd/flags.go
+
1
−
0
View file @
c4c63b43
...
...
@@ -100,6 +100,7 @@ const (
connectionServerTimeoutFlag
=
"serverTimeout"
connectionDisconnectFlag
=
"disconnect"
connectionAuthenticatedFlag
=
"authenticated"
connectionEphemeralFlag
=
"ephemeral"
///////////////// File Transfer subcommand flags //////////////////////////
fileSendFlag
=
"sendFile"
...
...
This diff is collapsed.
Click to expand it.
cmd/init.go
+
51
−
0
View file @
c4c63b43
...
...
@@ -123,6 +123,57 @@ func loadOrInitMessenger(forceLegacy bool, password []byte, storeDir, regCode st
return
messenger
}
// loadOrInitMessengerEphemeral will build a new ephemeral xxdk.E2e.
func
loadOrInitMessengerEphemeral
(
forceLegacy
bool
,
password
[]
byte
,
storeDir
,
regCode
string
,
cmixParams
xxdk
.
CMIXParams
,
e2eParams
xxdk
.
E2EParams
,
cbs
xxdk
.
AuthCallbacks
)
*
xxdk
.
E2e
{
jww
.
INFO
.
Printf
(
"Using normal sender"
)
// create a new client if none exist
if
_
,
err
:=
os
.
Stat
(
storeDir
);
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
// Initialize from scratch
ndfJson
,
err
:=
ioutil
.
ReadFile
(
viper
.
GetString
(
"ndf"
))
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
err
=
xxdk
.
NewCmix
(
string
(
ndfJson
),
storeDir
,
password
,
regCode
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
// Initialize from storage
net
,
err
:=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
// Load or initialize xxdk.ReceptionIdentity storage
identity
,
err
:=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
net
)
if
err
!=
nil
{
if
forceLegacy
{
jww
.
INFO
.
Printf
(
"Forcing legacy sender"
)
identity
,
err
=
xxdk
.
MakeLegacyReceptionIdentity
(
net
)
}
else
{
identity
,
err
=
xxdk
.
MakeReceptionIdentity
(
net
)
}
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
err
=
xxdk
.
StoreReceptionIdentity
(
identityStorageKey
,
identity
,
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
messenger
,
err
:=
xxdk
.
LoginEphemeral
(
net
,
cbs
,
identity
,
e2eParams
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
return
messenger
}
// loadOrInitNet will build a new xxdk.Cmix from existing storage
// or from a new storage that it will create if none already exists
func
loadOrInitNet
(
password
[]
byte
,
storeDir
,
regCode
string
,
...
...
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