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

Clean up authenticated package/

parent 1d25fdae
No related branches found
No related tags found
3 merge requests!510Release,!216Xx 3895/authenticated connection,!207WIP: Client Restructure
...@@ -92,11 +92,11 @@ func ConnectWithAuthentication(recipient contact.Contact, ...@@ -92,11 +92,11 @@ func ConnectWithAuthentication(recipient contact.Contact,
return nil, err return nil, err
} }
// Block waiting for auth to confirm // Block waiting for auth to confirm it timeouts
jww.DEBUG.Printf("Connection waiting for authenticated "+ jww.DEBUG.Printf("Connection waiting for authenticated "+
"connection with %s to be established...", recipient.ID.String()) "connection with %s to be established...", recipient.ID.String())
timeout := time.NewTimer(p.Timeout) timeout := time.NewTimer(p.Timeout)
defer timeout.Stop()
select { select {
case newConnection := <-authConnChan: case newConnection := <-authConnChan:
if newConnection == nil { if newConnection == nil {
...@@ -104,7 +104,6 @@ func ConnectWithAuthentication(recipient contact.Contact, ...@@ -104,7 +104,6 @@ func ConnectWithAuthentication(recipient contact.Contact,
"Unable to complete authenticated connection with partner %s", "Unable to complete authenticated connection with partner %s",
recipient.ID.String()) recipient.ID.String())
} }
return newConnection, nil return newConnection, nil
case <-timeout.C: case <-timeout.C:
return nil, errors.Errorf("Authenticated connection with "+ return nil, errors.Errorf("Authenticated connection with "+
......
...@@ -27,6 +27,15 @@ type client interface { ...@@ -27,6 +27,15 @@ type client interface {
// clientHandler provides an implementation of the client interface. // clientHandler provides an implementation of the client interface.
type clientHandler struct { type clientHandler struct {
// This will handle the client's auth.Callbacks
clientAuth
// This will handle the confirmation message sent by the serverHandler.
clientListener
}
// clientListener provides an implementation for client's listener.
// This will handle the confirmation message sent by the serverHandler.
type clientListener struct {
// connectionCallback allows an authenticated.Connection // connectionCallback allows an authenticated.Connection
// to be passed back upon establishment. // to be passed back upon establishment.
connectionCallback ConnectionCallback connectionCallback ConnectionCallback
...@@ -36,35 +45,40 @@ type clientHandler struct { ...@@ -36,35 +45,40 @@ type clientHandler struct {
connectionParams connect.Params connectionParams connect.Params
} }
// clientAuth provides an implementation for client's auth.Callbacks.
type clientAuth struct{}
// getClient returns a client interface to be used to handle // getClient returns a client interface to be used to handle
// auth.Callbacks and receive.Listener operations. // auth.Callbacks and receive.Listener operations.
func getClient(cb ConnectionCallback, func getClient(cb ConnectionCallback,
e2e clientE2e.Handler, p connect.Params) client { e2e clientE2e.Handler, p connect.Params) client {
return clientHandler{ return clientHandler{
clientListener: clientListener{
connectionCallback: cb, connectionCallback: cb,
connectionE2e: e2e, connectionE2e: e2e,
connectionParams: p, connectionParams: p,
},
} }
} }
// Request will be called when an auth Request message is processed. // Request will be called when an auth Request message is processed.
func (a clientHandler) Request(requestor contact.Contact, func (a clientAuth) Request(requestor contact.Contact,
receptionID receptionID.EphemeralIdentity, round rounds.Round) { receptionID receptionID.EphemeralIdentity, round rounds.Round) {
} }
// Confirm will be called when an auth Confirm message is processed. // Confirm will be called when an auth Confirm message is processed.
func (a clientHandler) Confirm(requestor contact.Contact, func (a clientAuth) Confirm(requestor contact.Contact,
receptionID receptionID.EphemeralIdentity, round rounds.Round) { receptionID receptionID.EphemeralIdentity, round rounds.Round) {
} }
// Reset will be called when an auth Reset operation occurs. // Reset will be called when an auth Reset operation occurs.
func (a clientHandler) Reset(requestor contact.Contact, func (a clientAuth) Reset(requestor contact.Contact,
receptionID receptionID.EphemeralIdentity, round rounds.Round) { receptionID receptionID.EphemeralIdentity, round rounds.Round) {
} }
// Hear handles the reception of an IdentityAuthentication by the // Hear handles the reception of an IdentityAuthentication by the
// server. // server.
func (a clientHandler) Hear(item receive.Message) { func (a clientListener) Hear(item receive.Message) {
// Process the message data into a protobuf // Process the message data into a protobuf
iar := &IdentityAuthentication{} iar := &IdentityAuthentication{}
err := proto.Unmarshal(item.Payload, iar) err := proto.Unmarshal(item.Payload, iar)
...@@ -122,6 +136,6 @@ func (a clientHandler) Hear(item receive.Message) { ...@@ -122,6 +136,6 @@ func (a clientHandler) Hear(item receive.Message) {
a.connectionParams)) a.connectionParams))
} }
func (a clientHandler) Name() string { func (a clientListener) Name() string {
return clientListenerName return clientListenerName
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment