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

Privatize sub-interfaces

parent 65988c4a
No related branches found
No related tags found
2 merge requests!510Release,!207WIP: Client Restructure
...@@ -299,5 +299,5 @@ type ClientErrorReport func(source, message, trace string) ...@@ -299,5 +299,5 @@ type ClientErrorReport func(source, message, trace string)
type clientCommsInterface interface { type clientCommsInterface interface {
followNetworkComms followNetworkComms
SendCmixCommsInterface SendCmixCommsInterface
nodes.RegisterNodeCommsInterface nodes.registerNodeCommsInterface
} }
...@@ -62,16 +62,16 @@ type MixCypher interface { ...@@ -62,16 +62,16 @@ type MixCypher interface {
MakeClientGatewayAuthMAC(salt, digest []byte) []byte MakeClientGatewayAuthMAC(salt, digest []byte) []byte
} }
// RegisterNodeCommsInterface is a sub-interface of client.Comms containing // registerNodeCommsInterface is a sub-interface of client.Comms containing
// the send function for registering with a cMix node. // the send function for registering with a cMix node.
type RegisterNodeCommsInterface interface { type registerNodeCommsInterface interface {
SendRequestClientKeyMessage(host *connect.Host, SendRequestClientKeyMessage(host *connect.Host,
message *pb.SignedClientKeyRequest) (*pb.SignedKeyResponse, error) message *pb.SignedClientKeyRequest) (*pb.SignedKeyResponse, error)
} }
// Session is a sub-interface of the storage.Session interface relevant to // session is a sub-interface of the storage.Session interface relevant to
// the methods used in this package. // the methods used in this package.
type Session interface { type session interface {
GetTransmissionID() *id.ID GetTransmissionID() *id.ID
IsPrecanned() bool IsPrecanned() bool
GetCmixGroup() *cyclic.Group GetCmixGroup() *cyclic.Group
......
...@@ -30,7 +30,7 @@ import ( ...@@ -30,7 +30,7 @@ import (
// The sync.Map's keep track of the node(s) that were in progress // The sync.Map's keep track of the node(s) that were in progress
// before an interruption and how many registration attempts have // before an interruption and how many registration attempts have
// been attempted. // been attempted.
func registerNodes(r *registrar, s Session, stop *stoppable.Single, func registerNodes(r *registrar, s session, stop *stoppable.Single,
inProgress, attempts *sync.Map) { inProgress, attempts *sync.Map) {
interval := time.Duration(500) * time.Millisecond interval := time.Duration(500) * time.Millisecond
...@@ -114,8 +114,8 @@ func registerNodes(r *registrar, s Session, stop *stoppable.Single, ...@@ -114,8 +114,8 @@ func registerNodes(r *registrar, s Session, stop *stoppable.Single,
// registerWithNode serves as a helper for registerNodes. It registers a user // registerWithNode serves as a helper for registerNodes. It registers a user
// with a specific in the client's NDF. // with a specific in the client's NDF.
func registerWithNode(sender gateway.Sender, comms RegisterNodeCommsInterface, func registerWithNode(sender gateway.Sender, comms registerNodeCommsInterface,
ngw network.NodeGateway, s Session, r *registrar, ngw network.NodeGateway, s session, r *registrar,
rng csprng.Source, stop *stoppable.Single) error { rng csprng.Source, stop *stoppable.Single) error {
nodeID, err := ngw.Node.GetNodeId() nodeID, err := ngw.Node.GetNodeId()
......
...@@ -34,9 +34,9 @@ type registrar struct { ...@@ -34,9 +34,9 @@ type registrar struct {
kv *versioned.KV kv *versioned.KV
mux sync.RWMutex mux sync.RWMutex
session Session session session
sender gateway.Sender sender gateway.Sender
comms RegisterNodeCommsInterface comms registerNodeCommsInterface
rng *fastRNG.StreamGenerator rng *fastRNG.StreamGenerator
c chan network.NodeGateway c chan network.NodeGateway
...@@ -44,8 +44,8 @@ type registrar struct { ...@@ -44,8 +44,8 @@ type registrar struct {
// LoadRegistrar loads a Registrar from disk or creates a new one if it does not // LoadRegistrar loads a Registrar from disk or creates a new one if it does not
// exist. // exist.
func LoadRegistrar(session Session, sender gateway.Sender, func LoadRegistrar(session session, sender gateway.Sender,
comms RegisterNodeCommsInterface, rngGen *fastRNG.StreamGenerator, comms registerNodeCommsInterface, rngGen *fastRNG.StreamGenerator,
c chan network.NodeGateway) (Registrar, error) { c chan network.NodeGateway) (Registrar, error) {
kv := session.GetKV().Prefix(prefix) kv := session.GetKV().Prefix(prefix)
......
...@@ -26,8 +26,8 @@ import ( ...@@ -26,8 +26,8 @@ import (
// requestKey is a helper function which constructs a ClientKeyRequest message. // requestKey is a helper function which constructs a ClientKeyRequest message.
// This message is sent to the passed gateway. It will further handle the // This message is sent to the passed gateway. It will further handle the
// request from the gateway. // request from the gateway.
func requestKey(sender gateway.Sender, comms RegisterNodeCommsInterface, func requestKey(sender gateway.Sender, comms registerNodeCommsInterface,
ngw network.NodeGateway, s Session, r *registrar, ngw network.NodeGateway, s session, r *registrar,
rng io.Reader, rng io.Reader,
stop *stoppable.Single) (*cyclic.Int, []byte, uint64, error) { stop *stoppable.Single) (*cyclic.Int, []byte, uint64, error) {
...@@ -92,7 +92,7 @@ func requestKey(sender gateway.Sender, comms RegisterNodeCommsInterface, ...@@ -92,7 +92,7 @@ func requestKey(sender gateway.Sender, comms RegisterNodeCommsInterface,
// makeSignedKeyRequest is a helper function which constructs a // makeSignedKeyRequest is a helper function which constructs a
// pb.SignedClientKeyRequest to send to the node/gateway pair the // pb.SignedClientKeyRequest to send to the node/gateway pair the
// user is trying to register with. // user is trying to register with.
func makeSignedKeyRequest(s Session, rng io.Reader, func makeSignedKeyRequest(s session, rng io.Reader,
gwId *id.ID, dhPub *cyclic.Int) (*pb.SignedClientKeyRequest, error) { gwId *id.ID, dhPub *cyclic.Int) (*pb.SignedClientKeyRequest, error) {
// Reconstruct client confirmation message // Reconstruct client confirmation message
......
...@@ -145,7 +145,7 @@ func (m mockSender) GetHostParams() connect.HostParams { ...@@ -145,7 +145,7 @@ func (m mockSender) GetHostParams() connect.HostParams {
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
///////////////// Mock storage.Session Interface ////////////////////////////// ///////////////// Mock storage.session Interface //////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
type mockSession struct { type mockSession struct {
...@@ -192,7 +192,7 @@ func (m mockSession) GetTransmissionRegistrationValidationSignature() []byte { ...@@ -192,7 +192,7 @@ func (m mockSession) GetTransmissionRegistrationValidationSignature() []byte {
///////////////// Mock Comms Interface /////////////////////////////////////// ///////////////// Mock Comms Interface ///////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Mock client comms object adhering to RegisterNodeCommsInterface for testing. // Mock client comms object adhering to registerNodeCommsInterface for testing.
type MockClientComms struct { type MockClientComms struct {
rsaPrivKey *rsa.PrivateKey rsaPrivKey *rsa.PrivateKey
dhPrivKey *cyclic.Int dhPrivKey *cyclic.Int
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment