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
5e6a3d2f
Commit
5e6a3d2f
authored
2 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
fix cmd idgen to properly handle existing session files
parent
2cfdb8bf
No related branches found
No related tags found
2 merge requests
!510
Release
,
!271
fix cmd idgen to properly handle existing session files
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cmd/backup.go
+11
-16
11 additions, 16 deletions
cmd/backup.go
cmd/init.go
+23
-24
23 additions, 24 deletions
cmd/init.go
cmd/precan.go
+12
-13
12 additions, 13 deletions
cmd/precan.go
cmd/proto.go
+13
-13
13 additions, 13 deletions
cmd/proto.go
with
59 additions
and
66 deletions
cmd/backup.go
+
11
−
16
View file @
5e6a3d2f
...
...
@@ -30,7 +30,8 @@ func loadOrInitBackup(backupPath string, backupPass string, password []byte, sto
// create a new client if none exist
var
net
*
xxdk
.
Cmix
var
identity
xxdk
.
ReceptionIdentity
if
_
,
err
:=
os
.
Stat
(
storeDir
);
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
_
,
err
:=
os
.
Stat
(
storeDir
)
if
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
// Initialize from scratch
ndfJson
,
err
:=
ioutil
.
ReadFile
(
viper
.
GetString
(
"ndf"
))
if
err
!=
nil
{
...
...
@@ -73,12 +74,16 @@ func loadOrInitBackup(backupPath string, backupPass string, password []byte, sto
backupIdListPath
,
err
)
}
}
}
// Initialize from storage
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
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
{
identity
,
err
=
xxdk
.
MakeLegacyReceptionIdentity
(
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
...
...
@@ -88,16 +93,6 @@ func loadOrInitBackup(backupPath string, backupPass string, password []byte, sto
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
else
{
// Initialize from storage
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
identity
,
err
=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
messenger
,
err
:=
xxdk
.
Login
(
net
,
authCbs
,
identity
,
e2eParams
)
...
...
This diff is collapsed.
Click to expand it.
cmd/init.go
+
23
−
24
View file @
5e6a3d2f
...
...
@@ -80,7 +80,8 @@ func loadOrInitMessenger(forceLegacy bool, password []byte, storeDir, regCode st
// create a new client if none exist
var
net
*
xxdk
.
Cmix
var
identity
xxdk
.
ReceptionIdentity
if
_
,
err
:=
os
.
Stat
(
storeDir
);
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
_
,
err
:=
os
.
Stat
(
storeDir
)
if
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
// Initialize from scratch
ndfJson
,
err
:=
ioutil
.
ReadFile
(
viper
.
GetString
(
"ndf"
))
if
err
!=
nil
{
...
...
@@ -88,11 +89,20 @@ func loadOrInitMessenger(forceLegacy bool, password []byte, storeDir, regCode st
}
err
=
xxdk
.
NewCmix
(
string
(
ndfJson
),
storeDir
,
password
,
regCode
)
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
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
)
...
...
@@ -107,16 +117,6 @@ func loadOrInitMessenger(forceLegacy bool, password []byte, storeDir, regCode st
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
else
{
// Initialize from storage
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
identity
,
err
=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
messenger
,
err
:=
xxdk
.
Login
(
net
,
authCbs
,
identity
,
e2eParams
)
...
...
@@ -135,7 +135,8 @@ func loadOrInitVanity(password []byte, storeDir, regCode, userIdPrefix string,
// create a new client if none exist
var
net
*
xxdk
.
Cmix
var
identity
xxdk
.
ReceptionIdentity
if
_
,
err
:=
os
.
Stat
(
storeDir
);
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
_
,
err
:=
os
.
Stat
(
storeDir
)
if
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
// Initialize from scratch
ndfJson
,
err
:=
ioutil
.
ReadFile
(
viper
.
GetString
(
"ndf"
))
if
err
!=
nil
{
...
...
@@ -144,11 +145,19 @@ func loadOrInitVanity(password []byte, storeDir, regCode, userIdPrefix string,
err
=
xxdk
.
NewVanityClient
(
string
(
ndfJson
),
storeDir
,
password
,
regCode
,
userIdPrefix
)
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
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
{
identity
,
err
=
xxdk
.
MakeLegacyReceptionIdentity
(
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
...
...
@@ -158,16 +167,6 @@ func loadOrInitVanity(password []byte, storeDir, regCode, userIdPrefix string,
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
else
{
// Initialize from storage
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
identity
,
err
=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
messenger
,
err
:=
xxdk
.
Login
(
net
,
authCbs
,
identity
,
e2eParams
)
...
...
This diff is collapsed.
Click to expand it.
cmd/precan.go
+
12
−
13
View file @
5e6a3d2f
...
...
@@ -30,7 +30,8 @@ func loadOrInitPrecan(precanId uint, password []byte, storeDir string,
// create a new client if none exist
var
net
*
xxdk
.
Cmix
var
identity
xxdk
.
ReceptionIdentity
if
_
,
err
:=
os
.
Stat
(
storeDir
);
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
_
,
err
:=
os
.
Stat
(
storeDir
)
if
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
// Initialize from scratch
ndfJson
,
err
:=
ioutil
.
ReadFile
(
viper
.
GetString
(
"ndf"
))
if
err
!=
nil
{
...
...
@@ -38,30 +39,28 @@ func loadOrInitPrecan(precanId uint, password []byte, storeDir string,
}
err
=
xxdk
.
NewPrecannedClient
(
precanId
,
string
(
ndfJson
),
storeDir
,
password
)
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
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
{
identity
,
err
=
xxdk
.
MakeLegacyReceptionIdentity
(
net
)
if
err
!=
nil
{
return
nil
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
err
=
xxdk
.
StoreReceptionIdentity
(
identityStorageKey
,
identity
,
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
else
{
// Initialize from storage
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
identity
,
err
=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
messenger
,
err
:=
xxdk
.
Login
(
net
,
authCbs
,
identity
,
e2eParams
)
...
...
This diff is collapsed.
Click to expand it.
cmd/proto.go
+
13
−
13
View file @
5e6a3d2f
...
...
@@ -28,7 +28,8 @@ func loadOrInitProto(protoUserPath string, password []byte, storeDir string,
// create a new client if none exist
var
net
*
xxdk
.
Cmix
var
identity
xxdk
.
ReceptionIdentity
if
_
,
err
:=
os
.
Stat
(
storeDir
);
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
_
,
err
:=
os
.
Stat
(
storeDir
)
if
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
{
// Initialize from scratch
ndfJson
,
err
:=
ioutil
.
ReadFile
(
viper
.
GetString
(
"ndf"
))
if
err
!=
nil
{
...
...
@@ -48,31 +49,30 @@ func loadOrInitProto(protoUserPath string, password []byte, storeDir string,
err
=
xxdk
.
NewProtoClient_Unsafe
(
string
(
ndfJson
),
storeDir
,
password
,
protoUser
)
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
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
{
identity
,
err
=
xxdk
.
MakeLegacyReceptionIdentity
(
net
)
if
err
!=
nil
{
return
nil
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
err
=
xxdk
.
StoreReceptionIdentity
(
identityStorageKey
,
identity
,
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
else
{
// Initialize from storage
net
,
err
=
xxdk
.
LoadCmix
(
storeDir
,
password
,
cmixParams
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
identity
,
err
=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
net
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
messenger
,
err
:=
xxdk
.
Login
(
net
,
authCbs
,
identity
,
e2eParams
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
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