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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
42e4fcba
Commit
42e4fcba
authored
Mar 17, 2022
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
base64 password support
parent
72043105
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!231
Revert "Update store to print changes to the partners list"
,
!187
Xx 3829/triggers
,
!184
Cleanup for ResetSession
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/root.go
+36
-9
36 additions, 9 deletions
cmd/root.go
with
36 additions
and
9 deletions
cmd/root.go
+
36
−
9
View file @
42e4fcba
...
@@ -525,7 +525,7 @@ func createClient() *api.Client {
...
@@ -525,7 +525,7 @@ func createClient() *api.Client {
initLog
(
logLevel
,
viper
.
GetString
(
"log"
))
initLog
(
logLevel
,
viper
.
GetString
(
"log"
))
jww
.
INFO
.
Printf
(
Version
())
jww
.
INFO
.
Printf
(
Version
())
pass
:=
viper
.
GetString
(
"password"
)
pass
:=
parsePassword
(
viper
.
GetString
(
"password"
)
)
storeDir
:=
viper
.
GetString
(
"session"
)
storeDir
:=
viper
.
GetString
(
"session"
)
regCode
:=
viper
.
GetString
(
"regcode"
)
regCode
:=
viper
.
GetString
(
"regcode"
)
precannedID
:=
viper
.
GetUint
(
"sendid"
)
precannedID
:=
viper
.
GetUint
(
"sendid"
)
...
@@ -544,17 +544,17 @@ func createClient() *api.Client {
...
@@ -544,17 +544,17 @@ func createClient() *api.Client {
if
precannedID
!=
0
{
if
precannedID
!=
0
{
err
=
api
.
NewPrecannedClient
(
precannedID
,
err
=
api
.
NewPrecannedClient
(
precannedID
,
string
(
ndfJSON
),
storeDir
,
[]
byte
(
pass
)
)
string
(
ndfJSON
),
storeDir
,
pass
)
}
else
if
protoUserPath
!=
""
{
}
else
if
protoUserPath
!=
""
{
protoUserJson
,
err
:=
utils
.
ReadFile
(
protoUserPath
)
protoUserJson
,
err
:=
utils
.
ReadFile
(
protoUserPath
)
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%v"
,
err
)
jww
.
FATAL
.
Panicf
(
"%v"
,
err
)
}
}
err
=
api
.
NewProtoClient_Unsafe
(
string
(
ndfJSON
),
storeDir
,
err
=
api
.
NewProtoClient_Unsafe
(
string
(
ndfJSON
),
storeDir
,
[]
byte
(
pass
)
,
protoUserJson
)
pass
,
protoUserJson
)
}
else
if
userIDprefix
!=
""
{
}
else
if
userIDprefix
!=
""
{
err
=
api
.
NewVanityClient
(
string
(
ndfJSON
),
storeDir
,
err
=
api
.
NewVanityClient
(
string
(
ndfJSON
),
storeDir
,
[]
byte
(
pass
)
,
regCode
,
userIDprefix
)
pass
,
regCode
,
userIDprefix
)
}
else
if
backupPath
!=
""
{
}
else
if
backupPath
!=
""
{
b
,
backupFile
:=
loadBackup
(
backupPath
,
string
(
backupPass
))
b
,
backupFile
:=
loadBackup
(
backupPath
,
string
(
backupPass
))
...
@@ -573,7 +573,7 @@ func createClient() *api.Client {
...
@@ -573,7 +573,7 @@ func createClient() *api.Client {
// Construct client from backup data
// Construct client from backup data
backupIdList
,
_
,
err
:=
api
.
NewClientFromBackup
(
string
(
ndfJSON
),
storeDir
,
backupIdList
,
_
,
err
:=
api
.
NewClientFromBackup
(
string
(
ndfJSON
),
storeDir
,
[]
byte
(
pass
)
,
backupPass
,
backupFile
)
pass
,
backupPass
,
backupFile
)
backupIdListPath
:=
viper
.
GetString
(
"backupIdList"
)
backupIdListPath
:=
viper
.
GetString
(
"backupIdList"
)
if
backupIdListPath
!=
""
{
if
backupIdListPath
!=
""
{
...
@@ -593,7 +593,7 @@ func createClient() *api.Client {
...
@@ -593,7 +593,7 @@ func createClient() *api.Client {
}
else
{
}
else
{
err
=
api
.
NewClient
(
string
(
ndfJSON
),
storeDir
,
err
=
api
.
NewClient
(
string
(
ndfJSON
),
storeDir
,
[]
byte
(
pass
)
,
regCode
)
pass
,
regCode
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -612,7 +612,7 @@ func createClient() *api.Client {
...
@@ -612,7 +612,7 @@ func createClient() *api.Client {
netParams
.
ForceMessagePickupRetry
=
viper
.
GetBool
(
"forceMessagePickupRetry"
)
netParams
.
ForceMessagePickupRetry
=
viper
.
GetBool
(
"forceMessagePickupRetry"
)
netParams
.
VerboseRoundTracking
=
viper
.
GetBool
(
"verboseRoundTracking"
)
netParams
.
VerboseRoundTracking
=
viper
.
GetBool
(
"verboseRoundTracking"
)
client
,
err
:=
api
.
OpenClient
(
storeDir
,
[]
byte
(
pass
)
,
netParams
)
client
,
err
:=
api
.
OpenClient
(
storeDir
,
pass
,
netParams
)
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
...
@@ -622,7 +622,7 @@ func createClient() *api.Client {
...
@@ -622,7 +622,7 @@ func createClient() *api.Client {
func
initClient
()
*
api
.
Client
{
func
initClient
()
*
api
.
Client
{
createClient
()
createClient
()
pass
:=
viper
.
GetString
(
"password"
)
pass
:=
parsePassword
(
viper
.
GetString
(
"password"
)
)
storeDir
:=
viper
.
GetString
(
"session"
)
storeDir
:=
viper
.
GetString
(
"session"
)
jww
.
DEBUG
.
Printf
(
"sessionDur: %v"
,
storeDir
)
jww
.
DEBUG
.
Printf
(
"sessionDur: %v"
,
storeDir
)
netParams
:=
params
.
GetDefaultNetwork
()
netParams
:=
params
.
GetDefaultNetwork
()
...
@@ -642,7 +642,7 @@ func initClient() *api.Client {
...
@@ -642,7 +642,7 @@ func initClient() *api.Client {
netParams
.
VerboseRoundTracking
=
viper
.
GetBool
(
"verboseRoundTracking"
)
netParams
.
VerboseRoundTracking
=
viper
.
GetBool
(
"verboseRoundTracking"
)
// load the client
// load the client
client
,
err
:=
api
.
Login
(
storeDir
,
[]
byte
(
pass
)
,
netParams
)
client
,
err
:=
api
.
Login
(
storeDir
,
pass
,
netParams
)
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
...
@@ -853,6 +853,16 @@ func getPrecanID(recipientID *id.ID) uint {
...
@@ -853,6 +853,16 @@ func getPrecanID(recipientID *id.ID) uint {
return
uint
(
recipientID
.
Bytes
()[
7
])
return
uint
(
recipientID
.
Bytes
()[
7
])
}
}
func
parsePassword
(
pwStr
string
)
[]
byte
{
if
strings
.
HasPrefix
(
pwStr
,
"0x"
)
{
return
getPWFromHexString
(
pwStr
[
2
:
])
}
else
if
strings
.
HasPrefix
(
pwStr
,
"b64:"
)
{
return
getPWFromb64String
(
pwStr
[
4
:
])
}
else
{
return
[]
byte
(
pwStr
)
}
}
func
parseRecipient
(
idStr
string
)
(
*
id
.
ID
,
bool
)
{
func
parseRecipient
(
idStr
string
)
(
*
id
.
ID
,
bool
)
{
if
idStr
==
"0"
{
if
idStr
==
"0"
{
return
nil
,
false
return
nil
,
false
...
@@ -905,6 +915,23 @@ func getUIDFromb64String(idStr string) *id.ID {
...
@@ -905,6 +915,23 @@ func getUIDFromb64String(idStr string) *id.ID {
return
ID
return
ID
}
}
func
getPWFromHexString
(
pwStr
string
)
[]
byte
{
pwBytes
,
err
:=
hex
.
DecodeString
(
fmt
.
Sprintf
(
"%0*d%s"
,
66
-
len
(
pwStr
),
0
,
pwStr
))
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
return
pwBytes
}
func
getPWFromb64String
(
pwStr
string
)
[]
byte
{
pwBytes
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
pwStr
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
return
pwBytes
}
func
getUIDFromString
(
idStr
string
)
*
id
.
ID
{
func
getUIDFromString
(
idStr
string
)
*
id
.
ID
{
idInt
,
err
:=
strconv
.
Atoi
(
idStr
)
idInt
,
err
:=
strconv
.
Atoi
(
idStr
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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