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
13c647c4
Commit
13c647c4
authored
2 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
debugging comments
parent
3704287c
No related branches found
No related tags found
3 merge requests
!510
Release
,
!267
Make BuildReceptionIdentity public, and make backup restore function return a...
,
!263
Hotfix/refactor cmd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
backup/backupRestore.go
+4
-0
4 additions, 0 deletions
backup/backupRestore.go
cmd/root.go
+3
-0
3 additions, 0 deletions
cmd/root.go
cmd/ud.go
+19
-33
19 additions, 33 deletions
cmd/ud.go
with
26 additions
and
33 deletions
backup/backupRestore.go
+
4
−
0
View file @
13c647c4
...
@@ -11,6 +11,7 @@ package backup
...
@@ -11,6 +11,7 @@ package backup
import
(
import
(
"github.com/pkg/errors"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/client/e2e/rekey"
"gitlab.com/elixxir/client/e2e/rekey"
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage"
...
@@ -38,6 +39,9 @@ func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword,
...
@@ -38,6 +39,9 @@ func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword,
"Failed to unmarshal decrypted client contents."
)
"Failed to unmarshal decrypted client contents."
)
}
}
jww
.
INFO
.
Printf
(
"Decrypted backup ID to Restore: %v"
,
backUp
.
ReceptionIdentity
.
ComputedID
)
usr
:=
user
.
NewUserFromBackup
(
backUp
)
usr
:=
user
.
NewUserFromBackup
(
backUp
)
def
,
err
:=
xxdk
.
ParseNDF
(
ndfJSON
)
def
,
err
:=
xxdk
.
ParseNDF
(
ndfJSON
)
...
...
This diff is collapsed.
Click to expand it.
cmd/root.go
+
3
−
0
View file @
13c647c4
...
@@ -596,6 +596,7 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) {
...
@@ -596,6 +596,7 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) {
pass
,
regCode
,
userIDprefix
)
pass
,
regCode
,
userIDprefix
)
}
else
if
backupPath
!=
""
{
}
else
if
backupPath
!=
""
{
jww
.
INFO
.
Printf
(
"Restoring user from %s"
,
backupPath
)
b
,
backupFile
:=
loadBackup
(
backupPath
,
string
(
backupPass
))
b
,
backupFile
:=
loadBackup
(
backupPath
,
string
(
backupPass
))
// Marshal the backup object in JSON
// Marshal the backup object in JSON
...
@@ -619,6 +620,8 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) {
...
@@ -619,6 +620,8 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) {
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
jww
.
INFO
.
Printf
(
"User Restored: %v"
,
knownReception
.
ID
)
backupIdListPath
:=
viper
.
GetString
(
"backupIdList"
)
backupIdListPath
:=
viper
.
GetString
(
"backupIdList"
)
if
backupIdListPath
!=
""
{
if
backupIdListPath
!=
""
{
// Marshal backed up ID list to JSON
// Marshal backed up ID list to JSON
...
...
This diff is collapsed.
Click to expand it.
cmd/ud.go
+
19
−
33
View file @
13c647c4
...
@@ -39,38 +39,16 @@ var udCmd = &cobra.Command{
...
@@ -39,38 +39,16 @@ var udCmd = &cobra.Command{
// get user and save contact to file
// get user and save contact to file
user
:=
client
.
GetReceptionIdentity
()
user
:=
client
.
GetReceptionIdentity
()
jww
.
INFO
.
Printf
(
"User: %s"
,
user
.
ID
)
jww
.
INFO
.
Printf
(
"
[UD]
User: %s"
,
user
.
ID
)
writeContact
(
user
.
GetContact
())
writeContact
(
user
.
GetContact
())
// // Set up reception handler
// swBoard := client.GetSwitchboard()
// recvCh := make(chan message.Receive, 10000)
// listenerID := swBoard.RegisterChannel("DefaultCLIReceiver",
// switchboard.AnyUser(), message.XxMessage, recvCh)
// jww.INFO.Printf("Message ListenerID: %v", listenerID)
// // Set up auth request handler, which simply prints the user ID of the
// // requester
// authMgr := client.GetAuthRegistrar()
// authMgr.AddGeneralRequestCallback(printChanRequest)
// // If unsafe channels, add auto-acceptor
// if viper.GetBool("unsafe-channel-creation") {
// authMgr.AddGeneralRequestCallback(func(
// requester contact.Contact) {
// jww.INFO.Printf("Got Request: %s", requester.ID)
// _, err := client.ConfirmAuthenticatedChannel(requester)
// if err != nil {
// jww.FATAL.Panicf("%+v", err)
// }
// })
// }
err
:=
client
.
StartNetworkFollower
(
50
*
time
.
Millisecond
)
err
:=
client
.
StartNetworkFollower
(
50
*
time
.
Millisecond
)
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
jww
.
TRACE
.
Printf
(
"[UD] Waiting for connection..."
)
// Wait until connected or crash on timeout
// Wait until connected or crash on timeout
connected
:=
make
(
chan
bool
,
10
)
connected
:=
make
(
chan
bool
,
10
)
client
.
GetCmix
()
.
AddHealthCallback
(
client
.
GetCmix
()
.
AddHealthCallback
(
...
@@ -79,9 +57,12 @@ var udCmd = &cobra.Command{
...
@@ -79,9 +57,12 @@ var udCmd = &cobra.Command{
})
})
waitUntilConnected
(
connected
)
waitUntilConnected
(
connected
)
jww
.
TRACE
.
Printf
(
"[UD] Connected!"
)
// Make user discovery manager
// Make user discovery manager
rng
:=
client
.
GetRng
()
rng
:=
client
.
GetRng
()
userToRegister
:=
viper
.
GetString
(
"register"
)
userToRegister
:=
viper
.
GetString
(
"register"
)
jww
.
TRACE
.
Printf
(
"[UD] Registering user %v..."
,
userToRegister
)
userDiscoveryMgr
,
err
:=
ud
.
NewManager
(
client
,
client
.
GetComms
(),
userDiscoveryMgr
,
err
:=
ud
.
NewManager
(
client
,
client
.
GetComms
(),
client
.
NetworkFollowerStatus
,
userToRegister
,
nil
)
client
.
NetworkFollowerStatus
,
userToRegister
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -95,6 +76,7 @@ var udCmd = &cobra.Command{
...
@@ -95,6 +76,7 @@ var udCmd = &cobra.Command{
}
}
}
}
jww
.
INFO
.
Printf
(
"[UD] Registered user %v"
,
userToRegister
)
var
newFacts
fact
.
FactList
var
newFacts
fact
.
FactList
phone
:=
viper
.
GetString
(
"addphone"
)
phone
:=
viper
.
GetString
(
"addphone"
)
...
@@ -116,24 +98,29 @@ var udCmd = &cobra.Command{
...
@@ -116,24 +98,29 @@ var udCmd = &cobra.Command{
}
}
for
i
:=
0
;
i
<
len
(
newFacts
);
i
++
{
for
i
:=
0
;
i
<
len
(
newFacts
);
i
++
{
jww
.
INFO
.
Printf
(
"[UD] Registering Fact: %v"
,
newFacts
[
i
])
r
,
err
:=
userDiscoveryMgr
.
SendRegisterFact
(
newFacts
[
i
])
r
,
err
:=
userDiscoveryMgr
.
SendRegisterFact
(
newFacts
[
i
])
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Failed to register fact: %s
\n
"
,
fmt
.
Printf
(
"Failed to register fact: %s
\n
"
,
newFacts
[
i
])
newFacts
[
i
])
jww
.
FATAL
.
Panicf
(
"Failed to send register fact: %+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"
[UD]
Failed to send register fact: %+v"
,
err
)
}
}
// TODO Store the code?
// TODO Store the code?
jww
.
INFO
.
Printf
(
"Fact Add Response: %+v"
,
r
)
jww
.
INFO
.
Printf
(
"
[UD]
Fact Add Response: %+v"
,
r
)
}
}
confirmID
:=
viper
.
GetString
(
"confirm"
)
confirmID
:=
viper
.
GetString
(
"confirm"
)
if
confirmID
!=
""
{
if
confirmID
!=
""
{
jww
.
INFO
.
Printf
(
"[UD] Confirming fact: %v"
,
confirmID
)
err
=
userDiscoveryMgr
.
ConfirmFact
(
confirmID
,
confirmID
)
err
=
userDiscoveryMgr
.
ConfirmFact
(
confirmID
,
confirmID
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Couldn't confirm fact: %s
\n
"
,
fmt
.
Printf
(
"Couldn't confirm fact: %s
\n
"
,
err
.
Error
())
err
.
Error
())
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
}
jww
.
INFO
.
Printf
(
"[UD] Confirmed %v"
,
confirmID
)
}
}
udContact
,
err
:=
userDiscoveryMgr
.
GetContact
()
udContact
,
err
:=
userDiscoveryMgr
.
GetContact
()
...
@@ -147,9 +134,7 @@ var udCmd = &cobra.Command{
...
@@ -147,9 +134,7 @@ var udCmd = &cobra.Command{
lookupIDStr
:=
viper
.
GetString
(
"lookup"
)
lookupIDStr
:=
viper
.
GetString
(
"lookup"
)
if
lookupIDStr
!=
""
{
if
lookupIDStr
!=
""
{
lookupID
:=
parseRecipient
(
lookupIDStr
)
lookupID
:=
parseRecipient
(
lookupIDStr
)
//if !ok {
jww
.
INFO
.
Printf
(
"[UD] Looking up %v"
,
lookupID
)
// jww.FATAL.Panicf("Could not parse recipient: %s", lookupIDStr)
//}
cb
:=
func
(
newContact
contact
.
Contact
,
err
error
)
{
cb
:=
func
(
newContact
contact
.
Contact
,
err
error
)
{
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -177,7 +162,7 @@ var udCmd = &cobra.Command{
...
@@ -177,7 +162,7 @@ var udCmd = &cobra.Command{
err
.
Error
())
err
.
Error
())
jww
.
FATAL
.
Panicf
(
"BATCHADD: Couldn't read file: %+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"BATCHADD: Couldn't read file: %+v"
,
err
)
}
}
jww
.
INFO
.
Printf
(
"BATCHADD: Running"
)
jww
.
INFO
.
Printf
(
"
[UD]
BATCHADD: Running"
)
restored
,
_
,
_
,
err
:=
xxmutils
.
RestoreContactsFromBackup
(
restored
,
_
,
_
,
err
:=
xxmutils
.
RestoreContactsFromBackup
(
idListFile
,
client
,
userDiscoveryMgr
,
nil
)
idListFile
,
client
,
userDiscoveryMgr
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -188,7 +173,7 @@ var udCmd = &cobra.Command{
...
@@ -188,7 +173,7 @@ var udCmd = &cobra.Command{
for
!
client
.
GetE2E
()
.
HasAuthenticatedChannel
(
uid
)
{
for
!
client
.
GetE2E
()
.
HasAuthenticatedChannel
(
uid
)
{
time
.
Sleep
(
time
.
Second
)
time
.
Sleep
(
time
.
Second
)
}
}
jww
.
INFO
.
Printf
(
"Authenticated channel established for %s"
,
uid
)
jww
.
INFO
.
Printf
(
"
[UD]
Authenticated channel established for %s"
,
uid
)
}
}
}
}
usernameSearchStr
:=
viper
.
GetString
(
"searchusername"
)
usernameSearchStr
:=
viper
.
GetString
(
"searchusername"
)
...
@@ -233,7 +218,7 @@ var udCmd = &cobra.Command{
...
@@ -233,7 +218,7 @@ var udCmd = &cobra.Command{
"Failed to remove user %s: %+v"
,
"Failed to remove user %s: %+v"
,
userToRemove
,
err
)
userToRemove
,
err
)
}
}
fmt
.
Printf
(
"Removed user from discovery: %s
\n
"
,
fmt
.
Printf
(
"
[UD]
Removed user from discovery: %s
\n
"
,
userToRemove
)
userToRemove
)
}
}
...
@@ -256,6 +241,7 @@ var udCmd = &cobra.Command{
...
@@ -256,6 +241,7 @@ var udCmd = &cobra.Command{
stream
:=
rng
.
GetStream
()
stream
:=
rng
.
GetStream
()
defer
stream
.
Close
()
defer
stream
.
Close
()
jww
.
INFO
.
Printf
(
"[UD] Search: %v"
,
facts
)
_
,
_
,
err
=
ud
.
Search
(
client
.
GetCmix
(),
_
,
_
,
err
=
ud
.
Search
(
client
.
GetCmix
(),
client
.
GetEventReporter
(),
client
.
GetEventReporter
(),
stream
,
client
.
GetE2E
()
.
GetGroup
(),
stream
,
client
.
GetE2E
()
.
GetGroup
(),
...
...
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