Skip to content
Snippets Groups Projects
Commit dc1dd2e4 authored by Josh Brooks's avatar Josh Brooks
Browse files

Merge branch 'roy/noContext' of gitlab.com:elixxir/client into XX-2645/KeyExchangeTest

parents 928edf76 aae122b6
Branches
Tags
No related merge requests found
Showing
with 294 additions and 202 deletions
...@@ -7,113 +7,121 @@ ...@@ -7,113 +7,121 @@
package api package api
import ( import (
"bufio"
"crypto"
"crypto/sha256"
"encoding/base64"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/context" "gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/context/params" "gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/context/stoppable" "gitlab.com/elixxir/client/keyExchange"
"gitlab.com/elixxir/client/context/switchboard"
"gitlab.com/elixxir/client/network" "gitlab.com/elixxir/client/network"
"gitlab.com/elixxir/client/permissioning"
"gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/switchboard"
"gitlab.com/elixxir/comms/client"
pb "gitlab.com/elixxir/comms/mixmessages" pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/crypto/csprng" "gitlab.com/elixxir/crypto/csprng"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/elixxir/crypto/large" "gitlab.com/elixxir/crypto/large"
"gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/crypto/tls"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/ndf"
"strings"
) )
type Client struct { type Client struct {
//generic RNG for client
rng *fastRNG.StreamGenerator
// the storage session securely stores data to disk and memoizes as is
// appropriate
storage *storage.Session storage *storage.Session
ctx *context.Context //the switchboard is used for inter-process signaling about received messages
switchboard *switchboard.Switchboard switchboard *switchboard.Switchboard
network context.NetworkManager //object used for communications
comms *client.Comms
// note that the manager has a pointer to the context in many cases, but
// this interface allows it to be mocked for easy testing without the
// loop
network interfaces.NetworkManager
//object used to register and communicate with permissioning
permissioning *permissioning.Permissioning
} }
// NewClient creates client storage, generates keys, connects, and registers // NewClient creates client storage, generates keys, connects, and registers
// with the network. Note that this does not register a username/identity, but // with the network. Note that this does not register a username/identity, but
// merely creates a new cryptographic identity for adding such information // merely creates a new cryptographic identity for adding such information
// at a later date. // at a later date.
func NewClient(netJSON, storageDir string, password []byte) (*Client, error) { func NewClient(ndfJSON, storageDir string, password []byte, registrationCode string) (*Client, error) {
if clientStorageExists(storageDir) {
return nil, errors.Errorf("client already exists at %s",
storageDir)
}
// Use fastRNG for RNG ops (AES fortuna based RNG using system RNG) // Use fastRNG for RNG ops (AES fortuna based RNG using system RNG)
rngStreamGen := fastRNG.NewStreamGenerator(12, 3, csprng.NewSystemRNG) rngStreamGen := fastRNG.NewStreamGenerator(12, 3, csprng.NewSystemRNG)
rngStream := rngStreamGen.GetStream() rngStream := rngStreamGen.GetStream()
// Parse the NDF // Parse the NDF
ndf, err := parseNDF(netJSON) def, err := parseNDF(ndfJSON)
if err != nil { if err != nil {
return nil, err return nil, err
} }
cmixGrp, e2eGrp := decodeGroups(ndf) cmixGrp, e2eGrp := decodeGroups(def)
user := createNewUser(rngStream, cmixGrp, e2eGrp) protoUser := createNewUser(rngStream, cmixGrp, e2eGrp)
// Create Storage // Create Storage
passwordStr := string(password) passwordStr := string(password)
storageSess, err := storage.New(storageDir, passwordStr, storageSess, err := storage.New(storageDir, passwordStr,
user.UID, user.Salt, user.RSAKey, user.IsPrecanned, protoUser.UID, protoUser.Salt, protoUser.RSAKey, protoUser.IsPrecanned,
user.CMixKey, user.E2EKey, cmixGrp, e2eGrp, rngStreamGen) protoUser.CMixKey, protoUser.E2EKey, cmixGrp, e2eGrp, rngStreamGen)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Save NDF to be used in the future // Save NDF to be used in the future
err = storageSess.SetNDF(netJSON) storageSess.SetBaseNDF(def)
if err != nil {
return nil, err
}
// Set up a new context //store the registration code for later use
ctx := &context.Context{ storageSess.SetRegCode(registrationCode)
Session: storageSess,
Switchboard: switchboard.New(), //execute the rest of the loading as normal
Rng: rngStreamGen, return loadClient(storageSess, rngStreamGen)
Manager: nil,
} }
// Initialize network and link it to context // NewPrecannedClient creates an insecure user with predetermined keys with nodes
netman, err := network.NewManager(ctx, params.GetDefaultNetwork(), ndf) // It creates client storage, generates keys, connects, and registers
// with the network. Note that this does not register a username/identity, but
// merely creates a new cryptographic identity for adding such information
// at a later date.
func NewPrecannedClient(precannedID uint, defJSON, storageDir string, password []byte) (*Client, error) {
// Use fastRNG for RNG ops (AES fortuna based RNG using system RNG)
rngStreamGen := fastRNG.NewStreamGenerator(12, 3, csprng.NewSystemRNG)
rngStream := rngStreamGen.GetStream()
// Parse the NDF
def, err := parseNDF(defJSON)
if err != nil { if err != nil {
return nil, err return nil, err
} }
ctx.Manager = netman cmixGrp, e2eGrp := decodeGroups(def)
client := &Client{ protoUser := createPrecannedUser(precannedID, rngStream, cmixGrp, e2eGrp)
storage: storageSess,
ctx: ctx,
switchboard: ctx.Switchboard,
network: netman,
}
// Now register with network, note that regCode is no longer required // Create Storage
err = client.RegisterWithPermissioning("") passwordStr := string(password)
storageSess, err := storage.New(storageDir, passwordStr,
protoUser.UID, protoUser.Salt, protoUser.RSAKey, protoUser.IsPrecanned,
protoUser.CMixKey, protoUser.E2EKey, cmixGrp, e2eGrp, rngStreamGen)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return client, nil // Save NDF to be used in the future
storageSess.SetBaseNDF(def)
//execute the rest of the loading as normal
return loadClient(storageSess, rngStreamGen)
} }
// LoadClient initalizes a client object from existing storage. // LoadClient initalizes a client object from existing storage.
func LoadClient(storageDir string, password []byte) (*Client, error) { func LoadClient(storageDir string, password []byte) (*Client, error) {
if !clientStorageExists(storageDir) {
return nil, errors.Errorf("client does not exist at %s",
storageDir)
}
// Use fastRNG for RNG ops (AES fortuna based RNG using system RNG) // Use fastRNG for RNG ops (AES fortuna based RNG using system RNG)
rngStreamGen := fastRNG.NewStreamGenerator(12, 3, csprng.NewSystemRNG) rngStreamGen := fastRNG.NewStreamGenerator(12, 3, csprng.NewSystemRNG)
...@@ -124,49 +132,97 @@ func LoadClient(storageDir string, password []byte) (*Client, error) { ...@@ -124,49 +132,97 @@ func LoadClient(storageDir string, password []byte) (*Client, error) {
return nil, err return nil, err
} }
netJSON, err := storageSess.GetNDF() //execute the rest of the loading as normal
return loadClient(storageSess, rngStreamGen)
}
// LoadClient initalizes a client object from existing storage.
func loadClient(session *storage.Session, rngStreamGen *fastRNG.StreamGenerator) (c *Client, err error) {
// Set up a new context
c = &Client{
storage: session,
switchboard: switchboard.New(),
rng: rngStreamGen,
comms: nil,
network: nil,
}
//get the user from session
user := c.storage.User()
cryptoUser := user.GetCryptographicIdentity()
//start comms
c.comms, err = client.NewClientComms(cryptoUser.GetUserID(),
rsa.CreatePublicKeyPem(cryptoUser.GetRSA().GetPublic()),
rsa.CreatePrivateKeyPem(cryptoUser.GetRSA()),
cryptoUser.GetSalt())
if err != nil { if err != nil {
return nil, err return nil, errors.WithMessage(err, "failed to load client")
} }
ndf, err := parseNDF(string(netJSON))
//get the NDF to pass into permissioning and the network manager
def := session.GetBaseNDF()
//initialize permissioning
c.permissioning, err = permissioning.Init(c.comms, def)
// check the client version is up to date to the network
err = c.checkVersion()
if err != nil { if err != nil {
return nil, err return nil, errors.WithMessage(err, "failed to load client")
} }
// Set up a new context //register with permissioning if necessary
ctx := &context.Context{ if c.storage.GetRegistrationStatus() == storage.KeyGenComplete {
Session: storageSess, err = c.registerWithPermissioning()
Switchboard: switchboard.New(), if err != nil {
Rng: rngStreamGen, return nil, errors.WithMessage(err, "failed to load client")
Manager: nil, }
} }
// Initialize network and link it to context // Initialize network and link it to context
netman, err := network.NewManager(ctx, params.GetDefaultNetwork(), ndf) c.network, err = network.NewManager(c.storage, c.switchboard, c.rng, c.comms,
params.GetDefaultNetwork(), def)
if err != nil { if err != nil {
return nil, err return nil, err
} }
ctx.Manager = netman
client := &Client{ return c, nil
storage: storageSess,
ctx: ctx,
switchboard: ctx.Switchboard,
network: netman,
} }
return client, nil // ----- Client Functions -----
// StartNetworkFollower kicks off the tracking of the network. It starts
// long running network client threads and returns an object for checking
// state and stopping those threads.
// Call this when returning from sleep and close when going back to
// sleep.
// Threads Started:
// - Network Follower (/network/follow.go)
// tracks the network events and hands them off to workers for handling
// - Historical Round Retrieval (/network/rounds/historical.go)
// Retrieves data about rounds which are too old to be stored by the client
// - Message Retrieval Worker Group (/network/rounds/retreive.go)
// Requests all messages in a given round from the gateway of the last node
// - Message Handling Worker Group (/network/message/reception.go)
// Decrypts and partitions messages when signals via the Switchboard
// - Health Tracker (/network/health)
func (c *Client) StartNetworkFollower() (stoppable.Stoppable, error) {
jww.INFO.Printf("StartNetworkFollower()")
multi := stoppable.NewMulti("client")
stopFollow, err := c.network.Follow()
if err != nil {
return nil, errors.WithMessage(err, "Failed to start following "+
"the network")
}
multi.Add(stopFollow)
// Key exchange
multi.Add(keyExchange.Start(c.switchboard, c.storage, c.network))
return multi, nil
} }
// ----- Client Functions -----
// RegisterListener registers a listener callback function that is called
// every time a new message matches the specified parameters.
func (c *Client) RegisterListenerCb(uid id.ID, msgType int, username string,
listenerCb func(msg Message)) {
jww.INFO.Printf("RegisterListener(%s, %d, %s, func())", uid, msgType,
username)
}
// SendE2E sends an end-to-end payload to the provided recipient with // SendE2E sends an end-to-end payload to the provided recipient with
// the provided msgType. Returns the list of rounds in which parts of // the provided msgType. Returns the list of rounds in which parts of
...@@ -199,6 +255,14 @@ func (c *Client) SendCMIX(payload []byte, recipient id.ID) (int, error) { ...@@ -199,6 +255,14 @@ func (c *Client) SendCMIX(payload []byte, recipient id.ID) (int, error) {
return 0, nil return 0, nil
} }
// RegisterListener registers a listener callback function that is called
// every time a new message matches the specified parameters.
func (c *Client) RegisterListenerCb(uid id.ID, msgType int, username string,
listenerCb func(msg Message)) {
jww.INFO.Printf("RegisterListener(%s, %d, %s, func())", uid, msgType,
username)
}
// RegisterForNotifications allows a client to register for push // RegisterForNotifications allows a client to register for push
// notifications. // notifications.
// Note that clients are not required to register for push notifications // Note that clients are not required to register for push notifications
...@@ -283,7 +347,7 @@ func (c *Client) RegisterPhone(phone string) ([]byte, error) { ...@@ -283,7 +347,7 @@ func (c *Client) RegisterPhone(phone string) ([]byte, error) {
} }
// ConfirmRegistration sends the user discovery agent a confirmation // ConfirmRegistration sends the user discovery agent a confirmation
// token (from Register Email/Phone) and code (string sent via Email // token (from register Email/Phone) and code (string sent via Email
// or SMS to confirm ownership) to confirm ownership. // or SMS to confirm ownership) to confirm ownership.
func (c *Client) ConfirmRegistration(token, code []byte) error { func (c *Client) ConfirmRegistration(token, code []byte) error {
jww.INFO.Printf("ConfirmRegistration(%s, %s)", token, code) jww.INFO.Printf("ConfirmRegistration(%s, %s)", token, code)
...@@ -363,15 +427,6 @@ func (c *Client) RegisterAuthRequestCb(cb func(contact Contact, ...@@ -363,15 +427,6 @@ func (c *Client) RegisterAuthRequestCb(cb func(contact Contact,
jww.INFO.Printf("RegisterAuthRequestCb(...)") jww.INFO.Printf("RegisterAuthRequestCb(...)")
} }
// StartNetworkRunner kicks off the longrunning network client threads
// and returns an object for checking state and stopping those threads.
// Call this when returning from sleep and close when going back to
// sleep.
func (c *Client) StartNetworkRunner() stoppable.Stoppable {
jww.INFO.Printf("StartNetworkRunner()")
return nil
}
// RegisterRoundEventsCb registers a callback for round // RegisterRoundEventsCb registers a callback for round
// events. // events.
func (c *Client) RegisterRoundEventsCb( func (c *Client) RegisterRoundEventsCb(
...@@ -380,69 +435,18 @@ func (c *Client) RegisterRoundEventsCb( ...@@ -380,69 +435,18 @@ func (c *Client) RegisterRoundEventsCb(
} }
// ----- Utility Functions ----- // ----- Utility Functions -----
// parseNDF parses the initial ndf string for the client. do not check the
// clientStorageExists returns true if an EKV (storage.Session) exists in the // signature, it is deprecated.
// given location or not.
func clientStorageExists(storageDir string) bool {
// Check if diretory exists.
// If directory exists, check if either .ekv.1 or .ekv.2 files exist in
// the directory.
return false
}
// parseNDF parses the initial ndf string for the client. This includes a
// network public key that is also used to verify integrity of the ndf.
func parseNDF(ndfString string) (*ndf.NetworkDefinition, error) { func parseNDF(ndfString string) (*ndf.NetworkDefinition, error) {
if ndfString == "" { if ndfString == "" {
return nil, errors.New("ndf file empty") return nil, errors.New("ndf file empty")
} }
ndfReader := bufio.NewReader(strings.NewReader(ndfString))
// ndfData is the json string defining the ndf
ndfData, err := ndfReader.ReadBytes('\n')
ndfData = ndfData[:len(ndfData)-1]
if err != nil {
return nil, err
}
// ndfSignature is the second line of the file, used to verify
// integrity.
ndfSignature, err := ndfReader.ReadBytes('\n')
if err != nil {
return nil, err
}
ndfSignature, err = base64.StdEncoding.DecodeString(
string(ndfSignature[:len(ndfSignature)-1]))
if err != nil {
return nil, err
}
ndf, _, err := ndf.DecodeNDF(ndfString) ndf, _, err := ndf.DecodeNDF(ndfString)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Load the TLS cert given to us, and from that get the RSA public key
cert, err := tls.LoadCertificate(ndf.Registration.TlsCertificate)
if err != nil {
return nil, err
}
pubKey := cert.PublicKey.(*rsa.PublicKey)
// Hash NDF JSON
rsaHash := sha256.New()
rsaHash.Write(ndfData)
// Verify signature
err = rsa.Verify(pubKey, crypto.SHA256,
rsaHash.Sum(nil), ndfSignature, nil)
if err != nil {
return nil, err
}
return ndf, nil return ndf, nil
} }
......
...@@ -8,38 +8,37 @@ package api ...@@ -8,38 +8,37 @@ package api
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
"gitlab.com/elixxir/client/globals"
"gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage"
) )
// Returns an error if registration fails. // Returns an error if registration fails.
func (c *Client) RegisterWithPermissioning(registrationCode string) error { func (c *Client) registerWithPermissioning() error {
ctx := c.ctx userData := c.storage.User()
netman := ctx.Manager //get the users public key
pubKey := userData.GetCryptographicIdentity().GetRSA().GetPublic()
//Check the regState is in proper state for registration //load the registration code
regState := c.storage.GetRegistrationStatus() regCode, err := c.storage.GetRegCode()
if regState != storage.KeyGenComplete { if err != nil {
return errors.Errorf("Attempting to register before key generation!") return errors.WithMessage(err, "failed to register with "+
"permissioning")
} }
userData := ctx.Session.User() //register with permissioning
regValidationSignature, err := c.permissioning.Register(pubKey, regCode)
// Register with the permissioning server and generate user information
regValidationSignature, err := netman.RegisterWithPermissioning(
registrationCode)
if err != nil { if err != nil {
globals.Log.INFO.Printf(err.Error()) return errors.WithMessage(err, "failed to register with "+
return err "permissioning")
} }
// update the session with the registration response //store the signature
userData.SetRegistrationValidationSignature(regValidationSignature) userData.SetRegistrationValidationSignature(regValidationSignature)
err = ctx.Session.ForwardRegistrationStatus(storage.PermissioningComplete) //update the registration status
err = c.storage.ForwardRegistrationStatus(storage.PermissioningComplete)
if err != nil { if err != nil {
return err return errors.WithMessage(err, "failed to update local state "+
"after registration with permissioning")
} }
return nil return nil
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
package api package api
import ( import (
"encoding/binary"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/crypto/csprng" "gitlab.com/elixxir/crypto/csprng"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
...@@ -80,3 +81,30 @@ func createNewUser(rng csprng.Source, cmix, e2e *cyclic.Group) user { ...@@ -80,3 +81,30 @@ func createNewUser(rng csprng.Source, cmix, e2e *cyclic.Group) user {
} }
// TODO: Add precanned user code structures here. // TODO: Add precanned user code structures here.
// creates a precanned user
func createPrecannedUser(precannedID uint, rng csprng.Source, cmix, e2e *cyclic.Group) user {
// DH Keygen
// FIXME: Why 256 bits? -- this is spec but not explained, it has
// to do with optimizing operations on one side and still preserves
// decent security -- cite this. Why valid for BOTH e2e and cmix?
e2eKeyBytes, err := csprng.GenerateInGroup(e2e.GetPBytes(), 256, rng)
if err != nil {
jww.FATAL.Panicf(err.Error())
}
// Salt, UID, etc gen
salt := make([]byte, SaltSize)
userID := id.ID{}
binary.BigEndian.PutUint64(userID[:], uint64(precannedID))
userID.SetType(id.User)
return user{
UID: &userID,
Salt: salt,
RSAKey: &rsa.PrivateKey{},
CMixKey: cmix.NewInt(1),
E2EKey: e2e.NewIntFromBytes(e2eKeyBytes),
IsPrecanned: true,
}
}
\ No newline at end of file
package api
import (
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/primitives/version"
)
func (c *Client) Version() version.Version {
v, err := version.ParseVersion(SEMVER)
if err != nil {
jww.FATAL.Panicf("Failed to parse the client version: %s", err)
}
return v
}
func (c *Client) checkVersion() error {
clientVersion := c.Version()
jww.INFO.Printf("Client Version: %s", clientVersion)
has, netVersion, err := c.permissioning.GetNetworkVersion()
if err != nil {
return errors.WithMessage(err, "failed to get check "+
"version compatibility")
}
if has {
jww.INFO.Printf("Minimum Network Version: %v", netVersion)
if !version.IsCompatible(netVersion, clientVersion) {
return errors.Errorf("Client and Minimum Network Version are "+
"incompatible\n"+
"\tMinimum Network: %s\n"+
"\tClient: %s", netVersion, clientVersion)
}
} else {
jww.WARN.Printf("Network requires no minnimim version")
}
return nil
}
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2020-08-10 10:46:23.193662 -0700 PDT m=+0.042594188
package api
const GITVERSION = `4ddf4b3 Merge branch 'XX-2471/XXPrimitives' into 'release'`
const SEMVER = "1.4.0"
const DEPENDENCIES = `module gitlab.com/elixxir/client
go 1.13
require (
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.4.2
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.9.1
github.com/smartystreets/assertions v1.0.1 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.6.2
gitlab.com/elixxir/comms v0.0.0-20200810165153-3039323b5656
gitlab.com/elixxir/crypto v0.0.0-20200806211835-b8ce4472f399
gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842
gitlab.com/elixxir/primitives v0.0.0-20200805174810-86b366d1dd2d
gitlab.com/xx_network/comms v0.0.0-20200806235452-3a82720833ba
gitlab.com/xx_network/crypto v0.0.0-20200806235322-ede3c15881ce
gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
gopkg.in/ini.v1 v1.52.0 // indirect
)
replace google.golang.org/grpc => github.com/grpc/grpc-go v1.27.1
`
...@@ -8,7 +8,7 @@ package bindings ...@@ -8,7 +8,7 @@ package bindings
import ( import (
"gitlab.com/elixxir/client/api" "gitlab.com/elixxir/client/api"
"gitlab.com/elixxir/client/context/stoppable" "gitlab.com/elixxir/client/stoppable"
) )
// Client is defined inside the api package. At minimum, it implements all of // Client is defined inside the api package. At minimum, it implements all of
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
package cmd package cmd
import ( import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/api" "gitlab.com/elixxir/client/api"
"gitlab.com/elixxir/client/globals"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"strings" "strings"
//"time" //"time"
...@@ -18,15 +18,15 @@ type callbackSearch struct{} ...@@ -18,15 +18,15 @@ type callbackSearch struct{}
func (cs callbackSearch) Callback(userID, pubKey []byte, err error) { func (cs callbackSearch) Callback(userID, pubKey []byte, err error) {
if err != nil { if err != nil {
globals.Log.INFO.Printf("UDB search failed: %v\n", err.Error()) jww.INFO.Printf("UDB search failed: %v\n", err.Error())
} else if len(pubKey) == 0 { } else if len(pubKey) == 0 {
globals.Log.INFO.Printf("Public Key returned is empty\n") jww.INFO.Printf("Public Key returned is empty\n")
} else { } else {
userID, err := id.Unmarshal(userID) userID, err := id.Unmarshal(userID)
if err != nil { if err != nil {
globals.Log.ERROR.Printf("Malformed user ID from successful UDB search: %v", err) jww.ERROR.Printf("Malformed user ID from successful UDB search: %v", err)
} }
globals.Log.INFO.Printf("UDB search successful. Returned user %v\n", jww.INFO.Printf("UDB search successful. Returned user %v\n",
userID) userID)
} }
} }
...@@ -38,7 +38,7 @@ func parseUdbMessage(msg string, client *api.Client) { ...@@ -38,7 +38,7 @@ func parseUdbMessage(msg string, client *api.Client) {
// Split the message on spaces // Split the message on spaces
args := strings.Fields(msg) args := strings.Fields(msg)
if len(args) < 3 { if len(args) < 3 {
globals.Log.ERROR.Printf("UDB command must have at least three arguments!") jww.ERROR.Printf("UDB command must have at least three arguments!")
} }
// The first arg is the command // The first arg is the command
// the second is the valueType // the second is the valueType
...@@ -48,8 +48,8 @@ func parseUdbMessage(msg string, client *api.Client) { ...@@ -48,8 +48,8 @@ func parseUdbMessage(msg string, client *api.Client) {
if strings.EqualFold(keyword, "SEARCH") { if strings.EqualFold(keyword, "SEARCH") {
//client.SearchForUser(args[2], searchCallback, 2*time.Minute) //client.SearchForUser(args[2], searchCallback, 2*time.Minute)
} else if strings.EqualFold(keyword, "REGISTER") { } else if strings.EqualFold(keyword, "REGISTER") {
globals.Log.ERROR.Printf("UDB REGISTER not allowed, it is already done during user registration") jww.ERROR.Printf("UDB REGISTER not allowed, it is already done during user registration")
} else { } else {
globals.Log.ERROR.Printf("UDB command not recognized!") jww.ERROR.Printf("UDB command not recognized!")
} }
} }
...@@ -11,7 +11,7 @@ package cmd ...@@ -11,7 +11,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gitlab.com/elixxir/client/globals" "gitlab.com/elixxir/client/api"
"gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/primitives/utils"
) )
...@@ -19,8 +19,8 @@ import ( ...@@ -19,8 +19,8 @@ import (
const currentVersion = "1.4.0" const currentVersion = "1.4.0"
func printVersion() { func printVersion() {
fmt.Printf("Elixxir Client v%s -- %s\n\n", globals.SEMVER, globals.GITVERSION) fmt.Printf("Elixxir Client v%s -- %s\n\n", api.SEMVER, api.GITVERSION)
fmt.Printf("Dependencies:\n\n%s\n", globals.DEPENDENCIES) fmt.Printf("Dependencies:\n\n%s\n", api.DEPENDENCIES)
} }
func init() { func init() {
......
package context
import (
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/switchboard"
"gitlab.com/elixxir/crypto/fastRNG"
)
type Context struct {
Session *storage.Session
Switchboard *switchboard.Switchboard
// note that the manager has a pointer to the context in many cases, but
// this interface allows it to be mocked for easy testing without the
// loop
Manager NetworkManager
//generic RNG for client
Rng *fastRNG.StreamGenerator
}
package interfaces
type HealthTracker interface {
AddChannel(chan bool)
AddFunc(f func(bool))
IsHealthy() bool
}
File moved
File moved
package context package interfaces
import ( import (
"gitlab.com/elixxir/client/context/message" "gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/context/params" "gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/context/stoppable" "gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/comms/network" "gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
...@@ -15,13 +15,9 @@ type NetworkManager interface { ...@@ -15,13 +15,9 @@ type NetworkManager interface {
SendCMIX(message format.Message, p params.CMIX) (id.Round, error) SendCMIX(message format.Message, p params.CMIX) (id.Round, error)
GetInstance() *network.Instance GetInstance() *network.Instance
GetHealthTracker() HealthTracker GetHealthTracker() HealthTracker
RegisterWithPermissioning(string) ([]byte, error) Follow() (stoppable.Stoppable, error)
GetRemoteVersion() (string, error) CheckGarbledMessages()
GetStoppable() stoppable.Stoppable
} }
type HealthTracker interface { //for use in key exchange which needs to be callable inside of network
AddChannel(chan bool) type SendE2E func(m message.Send, p params.E2E) ([]id.Round, error)
AddFunc(f func(bool)) \ No newline at end of file
IsHealthy() bool
}
File moved
File moved
File moved
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment