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
8f8c920e
Commit
8f8c920e
authored
Aug 9, 2022
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
Show 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 {
...
@@ -129,7 +129,7 @@ type UdNetworkStatus interface {
// You may use the UD server run by the xx network team by using E2e.GetUdAddressFromNdf.
// You may use the UD server run by the xx network team by using E2e.GetUdAddressFromNdf.
//
//
// Returns
// 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
,
func
NewOrLoadUd
(
e2eID
int
,
follower
UdNetworkStatus
,
username
string
,
registrationValidationSignature
,
username
string
,
registrationValidationSignature
,
cert
,
contactFile
[]
byte
,
address
string
)
(
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 {
...
@@ -38,9 +38,9 @@ type Manager struct {
// may cause unexpected behaviour.
// may cause unexpected behaviour.
factMux
sync
.
Mutex
factMux
sync
.
Mutex
//
alternativeUd is an alternate User discovery service to circumvent
//
ud is the tracker for the contact information of the specified UD server.
//
production.
This i
s
for
testing with a separately deployed UD service
.
// This i
n
for
mation is specified in NewOrLoad
.
alternativeUd
*
alternateUd
ud
*
userDiscovery
}
}
// NewOrLoad loads an existing Manager from storage or creates a
// NewOrLoad loads an existing Manager from storage or creates a
...
@@ -57,15 +57,16 @@ type Manager struct {
...
@@ -57,15 +57,16 @@ type Manager struct {
// provides if through the bindings.
// provides if through the bindings.
// - networkValidationSig is a signature provided by the network (i.e. the client registrar). This may
// - 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).
// 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.
// - cert is the TLS certificate for the UD server this call will connect with.
// - customContactFile is the data within a marshalled contact.Contact.
// - contactFile is the data within a marshalled contact.Contact. This represents the
// - customAddress is the IP address of the alternate UD server.
// 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
// 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
,
func
NewOrLoad
(
user
udE2e
,
comms
Comms
,
follower
udNetworkStatus
,
username
string
,
networkValidationSig
,
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()"
)
jww
.
INFO
.
Println
(
"ud.NewOrLoad()"
)
...
@@ -76,7 +77,7 @@ func NewOrLoad(user udE2e, comms Comms, follower udNetworkStatus,
...
@@ -76,7 +77,7 @@ func NewOrLoad(user udE2e, comms Comms, follower udNetworkStatus,
}
}
// Set alternative user discovery
// 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
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -187,18 +188,18 @@ func (m *Manager) GetContact() (contact.Contact, error) {
...
@@ -187,18 +188,18 @@ func (m *Manager) GetContact() (contact.Contact, error) {
return
contact
.
Contact
{},
err
return
contact
.
Contact
{},
err
}
}
// Return alternative User discovery contact if set
// Return alternative User discovery contact if set
if
m
.
alternativeU
d
!=
nil
{
if
m
.
u
d
!=
nil
{
// Unmarshal UD DH public key
// Unmarshal UD DH public key
alternativeDhPubKey
:=
grp
.
NewInt
(
1
)
alternativeDhPubKey
:=
grp
.
NewInt
(
1
)
if
err
:=
alternativeDhPubKey
.
if
err
:=
alternativeDhPubKey
.
UnmarshalJSON
(
m
.
alternativeU
d
.
dhPubKey
);
err
!=
nil
{
UnmarshalJSON
(
m
.
u
d
.
dhPubKey
);
err
!=
nil
{
return
contact
.
Contact
{},
return
contact
.
Contact
{},
errors
.
WithMessage
(
err
,
"Failed to unmarshal UD "
+
errors
.
WithMessage
(
err
,
"Failed to unmarshal UD "
+
"DH public key."
)
"DH public key."
)
}
}
return
contact
.
Contact
{
return
contact
.
Contact
{
ID
:
m
.
alternativeU
d
.
host
.
GetId
(),
ID
:
m
.
u
d
.
host
.
GetId
(),
DhPubKey
:
alternativeDhPubKey
,
DhPubKey
:
alternativeDhPubKey
,
OwnershipProof
:
nil
,
OwnershipProof
:
nil
,
Facts
:
nil
,
Facts
:
nil
,
...
@@ -234,8 +235,8 @@ func (m *Manager) GetContact() (contact.Contact, error) {
...
@@ -234,8 +235,8 @@ func (m *Manager) GetContact() (contact.Contact, error) {
// If the host does not exist, then it is added and returned.
// If the host does not exist, then it is added and returned.
func
(
m
*
Manager
)
getOrAddUdHost
()
(
*
connect
.
Host
,
error
)
{
func
(
m
*
Manager
)
getOrAddUdHost
()
(
*
connect
.
Host
,
error
)
{
// Return alternative User discovery service if it has been set
// Return alternative User discovery service if it has been set
if
m
.
alternativeU
d
!=
nil
{
if
m
.
u
d
!=
nil
{
return
m
.
alternativeU
d
.
host
,
nil
return
m
.
u
d
.
host
,
nil
}
}
netDef
:=
m
.
getCmix
()
.
GetInstance
()
.
GetPartialNdf
()
.
Get
()
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) {
...
@@ -53,8 +53,8 @@ func TestManager_SetAlternativeUserDiscovery(t *testing.T) {
m
,
_
:=
newTestManager
(
t
)
m
,
_
:=
newTestManager
(
t
)
altAddr
:=
"0.0.0.0:11420"
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
{
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 (
...
@@ -7,21 +7,16 @@ import (
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
)
)
// alternateUd is an alternative user discovery service.
// userDiscovery is the user discovery's contact information.
// This is used for testing, so client can avoid contacting
type
userDiscovery
struct
{
// the production server. This requires an alternative,
// deployed UD service.
type
alternateUd
struct
{
host
*
connect
.
Host
host
*
connect
.
Host
dhPubKey
[]
byte
dhPubKey
[]
byte
}
}
// setAlternateUserDiscovery sets the alternativeUd object within manager.
// setUserDiscovery sets the ud object within Manager.
// Once set, any user discovery operation will go through the alternative
// The specified the contact information will be used for
// user discovery service.
// all further Manager operations which contact the UD server.
//
func
(
m
*
Manager
)
setUserDiscovery
(
altCert
,
// To undo this operation, use UnsetAlternativeUserDiscovery.
func
(
m
*
Manager
)
setAlternateUserDiscovery
(
altCert
,
contactFile
[]
byte
,
altAddress
string
)
error
{
contactFile
[]
byte
,
altAddress
string
)
error
{
params
:=
connect
.
GetDefaultHostParams
()
params
:=
connect
.
GetDefaultHostParams
()
params
.
AuthEnabled
=
false
params
.
AuthEnabled
=
false
...
@@ -44,7 +39,7 @@ func (m *Manager) setAlternateUserDiscovery(altCert,
...
@@ -44,7 +39,7 @@ func (m *Manager) setAlternateUserDiscovery(altCert,
"not be constructed."
)
"not be constructed."
)
}
}
m
.
alternativeUd
=
&
alternateUd
{
m
.
ud
=
&
userDiscovery
{
host
:
host
,
host
:
host
,
dhPubKey
:
dhPubKey
,
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