Skip to content
Snippets Groups Projects
Commit a9a49b82 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

Merge remote-tracking branch 'origin/release' into release

parents de007321 ccf14785
No related branches found
No related tags found
No related merge requests found
......@@ -180,53 +180,99 @@ func OpenClient(storageDir string, password []byte, parameters params.Network) (
func Login(storageDir string, password []byte, parameters params.Network) (*Client, error) {
jww.INFO.Printf("Login()")
//Open the client
c, err := OpenClient(storageDir, password, parameters)
if err != nil {
return nil, err
}
//execute the rest of the loading as normal
//Attach the services interface
c.services = newServiceProcessiesList(c.runner)
//get the user from session
u := c.storage.User()
cryptoUser := u.GetCryptographicIdentity()
//start comms
c.comms, err = client.NewClientComms(cryptoUser.GetTransmissionID(),
rsa.CreatePublicKeyPem(cryptoUser.GetTransmissionRSA().GetPublic()),
rsa.CreatePrivateKeyPem(cryptoUser.GetTransmissionRSA()),
cryptoUser.GetTransmissionSalt())
//initilize comms
err = c.initComms()
if err != nil {
return nil, errors.WithMessage(err, "failed to load client")
return nil, err
}
//get the NDF to pass into permissioning and the network manager
def := c.storage.GetBaseNDF()
//initialize permissioning
c.permissioning, err = permissioning.Init(c.comms, def)
if def.Registration.Address != ""{
err = c.initPermissioning(def)
if err != nil {
return nil, errors.WithMessage(err, "failed to init "+
"permissioning handler")
return nil, err
}
}else{
jww.WARN.Printf("Registration with permissioning skipped due to " +
"blank permissionign address. Client will not be able to register " +
"or track network.")
}
// check the client version is up to date to the network
err = c.checkVersion()
// Initialize network and link it to context
c.network, err = network.NewManager(c.storage, c.switchboard, c.rng, c.comms,
parameters, def)
if err != nil {
return nil, errors.WithMessage(err, "failed to load client")
return nil, err
}
//register with permissioning if necessary
if c.storage.GetRegistrationStatus() == storage.KeyGenComplete {
jww.INFO.Printf("Client has not registered yet, attempting registration")
err = c.registerWithPermissioning()
//update gateway connections
err = c.network.GetInstance().UpdateGatewayConnections()
if err != nil {
jww.ERROR.Printf("Client has failed registration: %s", err)
return nil, errors.WithMessage(err, "failed to load client")
return nil, err
}
jww.INFO.Printf("Client sucsecfully registered with the network")
//initilize the auth tracker
c.auth = auth.NewManager(c.switchboard, c.storage, c.network)
return c, nil
}
// LoginWithNewBaseNDF_UNSAFE initializes a client object from existing storage
// while replacing the base NDF. This is designed for some specific deployment
// procedures and is generally unsafe.
func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte,
newBaseNdf string, parameters params.Network) (*Client, error) {
jww.INFO.Printf("LoginWithNewBaseNDF_UNSAFE()")
// Parse the NDF
def, err := parseNDF(newBaseNdf)
if err != nil {
return nil, err
}
//Open the client
c, err := OpenClient(storageDir, password, parameters)
if err != nil {
return nil, err
}
//Attach the services interface
c.services = newServiceProcessiesList(c.runner)
//initialize comms
err = c.initComms()
if err != nil {
return nil, err
}
//store the updated base NDF
c.storage.SetBaseNDF(def)
//initialize permissioning
if def.Registration.Address != ""{
err = c.initPermissioning(def)
if err != nil {
return nil, err
}
}else{
jww.WARN.Printf("Registration with permissioning skipped due to " +
"blank permissionign address. Client will not be able to register " +
"or track network.")
}
// Initialize network and link it to context
......@@ -236,6 +282,7 @@ func Login(storageDir string, password []byte, parameters params.Network) (*Clie
return nil, err
}
//update gateway connections
err = c.network.GetInstance().UpdateGatewayConnections()
if err != nil {
return nil, err
......@@ -247,6 +294,52 @@ func Login(storageDir string, password []byte, parameters params.Network) (*Clie
return c, nil
}
func (c *Client)initComms()error{
var err error
//get the user from session
u := c.storage.User()
cryptoUser := u.GetCryptographicIdentity()
//start comms
c.comms, err = client.NewClientComms(cryptoUser.GetTransmissionID(),
rsa.CreatePublicKeyPem(cryptoUser.GetTransmissionRSA().GetPublic()),
rsa.CreatePrivateKeyPem(cryptoUser.GetTransmissionRSA()),
cryptoUser.GetTransmissionSalt())
if err != nil {
return errors.WithMessage(err, "failed to load client")
}
return nil
}
func (c *Client)initPermissioning(def *ndf.NetworkDefinition)error{
var err error
//initialize permissioning
c.permissioning, err = permissioning.Init(c.comms, def)
if err != nil {
return errors.WithMessage(err, "failed to init "+
"permissioning handler")
}
// check the client version is up to date to the network
err = c.checkVersion()
if err != nil {
return errors.WithMessage(err, "failed to load client")
}
//register with permissioning if necessary
if c.storage.GetRegistrationStatus() == storage.KeyGenComplete {
jww.INFO.Printf("Client has not registered yet, attempting registration")
err = c.registerWithPermissioning()
if err != nil {
jww.ERROR.Printf("Client has failed registration: %s", err)
return errors.WithMessage(err, "failed to load client")
}
jww.INFO.Printf("Client sucsecfully registered with the network")
}
return nil
}
// ----- Client Functions -----
// StartNetworkFollower kicks off the tracking of the network. It starts
// long running network client threads and returns an object for checking
......@@ -346,7 +439,7 @@ func (c *Client) GetHealth() interfaces.HealthTracker {
return c.network.GetHealthTracker()
}
// Returns the switchboard for Identity
// Returns the switchboard for Registration
func (c *Client) GetSwitchboard() interfaces.Switchboard {
jww.INFO.Printf("GetSwitchboard()")
return c.switchboard
......
......@@ -17,12 +17,12 @@ require (
github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/viper v1.7.1
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228
gitlab.com/elixxir/comms v0.0.4-0.20210223182501-0b9a9fc80f48
gitlab.com/elixxir/crypto v0.0.7-0.20210216174551-f806f79610eb
gitlab.com/elixxir/comms v0.0.4-0.20210223210438-35bdbcaf78be
gitlab.com/elixxir/crypto v0.0.7-0.20210223210315-b2072c080b0f
gitlab.com/elixxir/ekv v0.1.4
gitlab.com/elixxir/primitives v0.0.3-0.20210223180234-8e5d82635c20
gitlab.com/xx_network/comms v0.0.4-0.20210216174438-0790d1f1f225
gitlab.com/xx_network/crypto v0.0.5-0.20210216174356-e81e1ddf8fb7
gitlab.com/elixxir/primitives v0.0.3-0.20210223210226-cccb5f7d4839
gitlab.com/xx_network/comms v0.0.4-0.20210223210205-6d1cb7fde5d1
gitlab.com/xx_network/crypto v0.0.5-0.20210223210125-9c1a8a8f1ec6
gitlab.com/xx_network/primitives v0.0.4-0.20210219231511-983054dbee36
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
......
......@@ -259,6 +259,8 @@ gitlab.com/elixxir/comms v0.0.4-0.20210218234550-f2e03b19bdb2 h1:p5GunVi5sP9atTw
gitlab.com/elixxir/comms v0.0.4-0.20210218234550-f2e03b19bdb2/go.mod h1:GCbfPWB7VF5ZeDsLBCwfy0JiquG4OK6gsRjaIS66+yg=
gitlab.com/elixxir/comms v0.0.4-0.20210223182501-0b9a9fc80f48 h1:fV6kL7PVZ+uR+TXGChGkCGdEM/DwThmQMcEhZTORt0w=
gitlab.com/elixxir/comms v0.0.4-0.20210223182501-0b9a9fc80f48/go.mod h1:GCbfPWB7VF5ZeDsLBCwfy0JiquG4OK6gsRjaIS66+yg=
gitlab.com/elixxir/comms v0.0.4-0.20210223210438-35bdbcaf78be h1:+2OeULnvHDy52gP+KtyBwhOYO1Q3eJOIWI/cV4PRM1U=
gitlab.com/elixxir/comms v0.0.4-0.20210223210438-35bdbcaf78be/go.mod h1:NcZ0SiO2Lf/+nXK0weAgmTiocO6rz1Inl3mfL5go3Ac=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4 h1:28ftZDeYEko7xptCZzeFWS1Iam95dj46TWFVVlKmw6A=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c=
gitlab.com/elixxir/crypto v0.0.3 h1:znCt/x2bL4y8czTPaaFkwzdgSgW3BJc/1+dxyf1jqVw=
......@@ -267,6 +269,8 @@ gitlab.com/elixxir/crypto v0.0.7-0.20210210215733-951b4e717763 h1:MUFs4H4kTdPm/f
gitlab.com/elixxir/crypto v0.0.7-0.20210210215733-951b4e717763/go.mod h1:ucX9BoKoDlE6e3yjnTuVD2mc72nQUket44DxISyivUw=
gitlab.com/elixxir/crypto v0.0.7-0.20210216174551-f806f79610eb h1:aPcrTC0QdrPqz4NgoAt5sfXt/+EFrNUwIns0s0VCQmg=
gitlab.com/elixxir/crypto v0.0.7-0.20210216174551-f806f79610eb/go.mod h1:CLP8kULKW9A5oZHQ1zMCx4swMhBw2IMO68z4U/FkvcU=
gitlab.com/elixxir/crypto v0.0.7-0.20210223210315-b2072c080b0f h1:VQDGEmfw6CLfmiN2asiNOJrodkDEGYVXDBDNfXsjTmk=
gitlab.com/elixxir/crypto v0.0.7-0.20210223210315-b2072c080b0f/go.mod h1:onm3bf+h/yIza245YXHuUW2hUQ1Ga8K4doXk5AKnrgg=
gitlab.com/elixxir/ekv v0.1.4 h1:NLVMwsFEKArWcsDHu2DbXlm9374iSgn7oIA3rVSsvjc=
gitlab.com/elixxir/ekv v0.1.4/go.mod h1:e6WPUt97taFZe5PFLPb1Dupk7tqmDCTQu1kkstqJvw4=
gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg=
......@@ -280,11 +284,15 @@ gitlab.com/elixxir/primitives v0.0.3-0.20210216174458-2a23825c1eb1 h1:BfcaQtKgIb
gitlab.com/elixxir/primitives v0.0.3-0.20210216174458-2a23825c1eb1/go.mod h1:Wpz7WGZ/CpO6oHNmVTgTNBETTRXi40arWjom1uwu/1s=
gitlab.com/elixxir/primitives v0.0.3-0.20210223180234-8e5d82635c20 h1:76cC9BusM1hozdeEIosvfTXm/bYa/IVEY8Z9BvCrxq8=
gitlab.com/elixxir/primitives v0.0.3-0.20210223180234-8e5d82635c20/go.mod h1:Wpz7WGZ/CpO6oHNmVTgTNBETTRXi40arWjom1uwu/1s=
gitlab.com/elixxir/primitives v0.0.3-0.20210223210226-cccb5f7d4839 h1:BvHO58ibn08sxll46vLIngFf37Ab76GV3xC+DM2m/Uo=
gitlab.com/elixxir/primitives v0.0.3-0.20210223210226-cccb5f7d4839/go.mod h1:LnvSPo0OMyHV4YMtnFelXwPu2UtU38h6DZrwUry6fjU=
gitlab.com/xx_network/comms v0.0.0-20200805174823-841427dd5023/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw=
gitlab.com/xx_network/comms v0.0.4-0.20210210215624-622913c0a215 h1:f+cobRegYJH2x6cFkf1RfJEGFnX/vq2hGLltFC+g4Bk=
gitlab.com/xx_network/comms v0.0.4-0.20210210215624-622913c0a215/go.mod h1:P81n1Rv0so+uIWGkGDEUt/bEvpksM6yfB0iB22rbFx4=
gitlab.com/xx_network/comms v0.0.4-0.20210216174438-0790d1f1f225 h1:ZVxPD76xDLdTSGY2w/aGRMiiry7SauD8sq4c+see6aM=
gitlab.com/xx_network/comms v0.0.4-0.20210216174438-0790d1f1f225/go.mod h1:e7dy2wznC4U4bG/U3xFGYYsnnd8zHOhoSxzFkGPQYX4=
gitlab.com/xx_network/comms v0.0.4-0.20210223210205-6d1cb7fde5d1 h1:AVKHbi69RA9DRIwgEPfRqCucmpsheskU9g+a4mGkDKo=
gitlab.com/xx_network/comms v0.0.4-0.20210223210205-6d1cb7fde5d1/go.mod h1:H10pJ7id+76aJeC1zP9F/N8cFBj1KtmkWHAmDILwZMw=
gitlab.com/xx_network/crypto v0.0.3/go.mod h1:DF2HYvvCw9wkBybXcXAgQMzX+MiGbFPjwt3t17VRqRE=
gitlab.com/xx_network/crypto v0.0.4 h1:lpKOL5mTJ2awWMfgBy30oD/UvJVrWZzUimSHlOdZZxo=
gitlab.com/xx_network/crypto v0.0.4/go.mod h1:+lcQEy+Th4eswFgQDwT0EXKp4AXrlubxalwQFH5O0Mk=
......@@ -292,6 +300,8 @@ gitlab.com/xx_network/crypto v0.0.5-0.20210210215543-446333e9022e h1:wRRIu5sB+5t
gitlab.com/xx_network/crypto v0.0.5-0.20210210215543-446333e9022e/go.mod h1:NiPI62thPru+eYlBucjl2/OLUND3wKLOhPrIHvK/nCA=
gitlab.com/xx_network/crypto v0.0.5-0.20210216174356-e81e1ddf8fb7 h1:vyL+m7D7w+RgMPARzcKCR8UMGC2foqNU6cSb1J6Dkis=
gitlab.com/xx_network/crypto v0.0.5-0.20210216174356-e81e1ddf8fb7/go.mod h1:8J+/VBcMlBj2sZuSDaVKI/i58awFZ5Zdb4JdEwGVrqo=
gitlab.com/xx_network/crypto v0.0.5-0.20210223210125-9c1a8a8f1ec6 h1:VOHKnXEeNsE7HV6jXRAnitaMz4Bk9+HNeGD65/Y14YM=
gitlab.com/xx_network/crypto v0.0.5-0.20210223210125-9c1a8a8f1ec6/go.mod h1:hv5iBFSfmrhTkS8cAu1+/SlXXDzpHhZou+cgBSf8hAI=
gitlab.com/xx_network/primitives v0.0.0-20200803231956-9b192c57ea7c/go.mod h1:wtdCMr7DPePz9qwctNoAUzZtbOSHSedcK++3Df3psjA=
gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da h1:CCVslUwNC7Ul7NG5nu3ThGTSVUt1TxNRX+47f5TUwnk=
gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da/go.mod h1:OK9xevzWCaPO7b1wiluVJGk7R5ZsuC7pHY5hteZFQug=
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment