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
8f8c920e
Commit
8f8c920e
authored
2 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Fix documentation
parent
04343023
No related branches found
No related tags found
3 merge requests
!510
Release
,
!327
Fix documentation
,
!323
Xx 4019/new or load alt ud
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bindings/ud.go
+1
-1
1 addition, 1 deletion
bindings/ud.go
ud/manager.go
+15
-14
15 additions, 14 deletions
ud/manager.go
ud/manager_test.go
+2
-2
2 additions, 2 deletions
ud/manager_test.go
ud/ud.go
+7
-12
7 additions, 12 deletions
ud/ud.go
with
25 additions
and
29 deletions
bindings/ud.go
+
1
−
1
View file @
8f8c920e
...
...
@@ -129,7 +129,7 @@ type UdNetworkStatus interface {
// You may use the UD server run by the xx network team by using E2e.GetUdAddressFromNdf.
//
// Returns
// - A Manager object which is registered to the specified
alternate
UD service.
// - A Manager object which is registered to the specified UD service.
func
NewOrLoadUd
(
e2eID
int
,
follower
UdNetworkStatus
,
username
string
,
registrationValidationSignature
,
cert
,
contactFile
[]
byte
,
address
string
)
(
...
...
This diff is collapsed.
Click to expand it.
ud/manager.go
+
15
−
14
View file @
8f8c920e
...
...
@@ -38,9 +38,9 @@ type Manager struct {
// may cause unexpected behaviour.
factMux
sync
.
Mutex
//
alternativeUd is an alternate User discovery service to circumvent
//
production.
This i
s
for
testing with a separately deployed UD service
.
alternativeUd
*
alternateUd
//
ud is the tracker for the contact information of the specified UD server.
// This i
n
for
mation is specified in NewOrLoad
.
ud
*
userDiscovery
}
// NewOrLoad loads an existing Manager from storage or creates a
...
...
@@ -57,15 +57,16 @@ type Manager struct {
// provides if through the bindings.
// - networkValidationSig is a signature provided by the network (i.e. the client registrar). This may
// be nil, however UD may return an error in some cases (e.g. in a production level environment).
// - customCert is the TLS certificate for the alternate UD server.
// - customContactFile is the data within a marshalled contact.Contact.
// - customAddress is the IP address of the alternate UD server.
// - cert is the TLS certificate for the UD server this call will connect with.
// - contactFile is the data within a marshalled contact.Contact. This represents the
// contact file of the server this call will connect with.
// - address is the IP address of the UD server this call will connect with.
//
// Returns
// - A Manager object which is registered to the specified
alternate
UD service.
// - A Manager object which is registered to the specified UD service.
func
NewOrLoad
(
user
udE2e
,
comms
Comms
,
follower
udNetworkStatus
,
username
string
,
networkValidationSig
,
c
ustomCert
,
customC
ontactFile
[]
byte
,
customA
ddress
string
)
(
*
Manager
,
error
)
{
c
ert
,
c
ontactFile
[]
byte
,
a
ddress
string
)
(
*
Manager
,
error
)
{
jww
.
INFO
.
Println
(
"ud.NewOrLoad()"
)
...
...
@@ -76,7 +77,7 @@ func NewOrLoad(user udE2e, comms Comms, follower udNetworkStatus,
}
// Set alternative user discovery
err
=
m
.
set
Alternate
UserDiscovery
(
c
ustomCert
,
customC
ontactFile
,
customA
ddress
)
err
=
m
.
setUserDiscovery
(
c
ert
,
c
ontactFile
,
a
ddress
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -187,18 +188,18 @@ func (m *Manager) GetContact() (contact.Contact, error) {
return
contact
.
Contact
{},
err
}
// Return alternative User discovery contact if set
if
m
.
alternativeU
d
!=
nil
{
if
m
.
u
d
!=
nil
{
// Unmarshal UD DH public key
alternativeDhPubKey
:=
grp
.
NewInt
(
1
)
if
err
:=
alternativeDhPubKey
.
UnmarshalJSON
(
m
.
alternativeU
d
.
dhPubKey
);
err
!=
nil
{
UnmarshalJSON
(
m
.
u
d
.
dhPubKey
);
err
!=
nil
{
return
contact
.
Contact
{},
errors
.
WithMessage
(
err
,
"Failed to unmarshal UD "
+
"DH public key."
)
}
return
contact
.
Contact
{
ID
:
m
.
alternativeU
d
.
host
.
GetId
(),
ID
:
m
.
u
d
.
host
.
GetId
(),
DhPubKey
:
alternativeDhPubKey
,
OwnershipProof
:
nil
,
Facts
:
nil
,
...
...
@@ -234,8 +235,8 @@ func (m *Manager) GetContact() (contact.Contact, error) {
// If the host does not exist, then it is added and returned.
func
(
m
*
Manager
)
getOrAddUdHost
()
(
*
connect
.
Host
,
error
)
{
// Return alternative User discovery service if it has been set
if
m
.
alternativeU
d
!=
nil
{
return
m
.
alternativeU
d
.
host
,
nil
if
m
.
u
d
!=
nil
{
return
m
.
u
d
.
host
,
nil
}
netDef
:=
m
.
getCmix
()
.
GetInstance
()
.
GetPartialNdf
()
.
Get
()
...
...
This diff is collapsed.
Click to expand it.
ud/manager_test.go
+
2
−
2
View file @
8f8c920e
...
...
@@ -53,8 +53,8 @@ func TestManager_SetAlternativeUserDiscovery(t *testing.T) {
m
,
_
:=
newTestManager
(
t
)
altAddr
:=
"0.0.0.0:11420"
err
:=
m
.
set
Alternate
UserDiscovery
([]
byte
(
testCert
),
[]
byte
(
testContact
),
string
([]
byte
(
altAddr
)))
err
:=
m
.
setUserDiscovery
([]
byte
(
testCert
),
[]
byte
(
testContact
),
string
([]
byte
(
altAddr
)))
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error in set
Alternate
UserDiscovery: %v"
,
err
)
t
.
Fatalf
(
"Unexpected error in setUserDiscovery: %v"
,
err
)
}
}
This diff is collapsed.
Click to expand it.
ud/
alternate
.go
→
ud/
ud
.go
+
7
−
12
View file @
8f8c920e
...
...
@@ -7,21 +7,16 @@ import (
"gitlab.com/xx_network/primitives/id"
)
// alternateUd is an alternative user discovery service.
// This is used for testing, so client can avoid contacting
// the production server. This requires an alternative,
// deployed UD service.
type
alternateUd
struct
{
// userDiscovery is the user discovery's contact information.
type
userDiscovery
struct
{
host
*
connect
.
Host
dhPubKey
[]
byte
}
// setAlternateUserDiscovery sets the alternativeUd object within manager.
// Once set, any user discovery operation will go through the alternative
// user discovery service.
//
// To undo this operation, use UnsetAlternativeUserDiscovery.
func
(
m
*
Manager
)
setAlternateUserDiscovery
(
altCert
,
// setUserDiscovery sets the ud object within Manager.
// The specified the contact information will be used for
// all further Manager operations which contact the UD server.
func
(
m
*
Manager
)
setUserDiscovery
(
altCert
,
contactFile
[]
byte
,
altAddress
string
)
error
{
params
:=
connect
.
GetDefaultHostParams
()
params
.
AuthEnabled
=
false
...
...
@@ -44,7 +39,7 @@ func (m *Manager) setAlternateUserDiscovery(altCert,
"not be constructed."
)
}
m
.
alternativeUd
=
&
alternateUd
{
m
.
ud
=
&
userDiscovery
{
host
:
host
,
dhPubKey
:
dhPubKey
,
}
...
...
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