diff --git a/connections/authenticated/authenticated.go b/connections/authenticated/authenticated.go index ea4e9ef2e33275e95b820abfb7c659de9bf2a920..3bf494887d634ec58cad88898f3da4700d50ec75 100644 --- a/connections/authenticated/authenticated.go +++ b/connections/authenticated/authenticated.go @@ -92,11 +92,11 @@ func ConnectWithAuthentication(recipient contact.Contact, return nil, err } - // Block waiting for auth to confirm + // Block waiting for auth to confirm it timeouts jww.DEBUG.Printf("Connection waiting for authenticated "+ "connection with %s to be established...", recipient.ID.String()) - timeout := time.NewTimer(p.Timeout) + defer timeout.Stop() select { case newConnection := <-authConnChan: if newConnection == nil { @@ -104,7 +104,6 @@ func ConnectWithAuthentication(recipient contact.Contact, "Unable to complete authenticated connection with partner %s", recipient.ID.String()) } - return newConnection, nil case <-timeout.C: return nil, errors.Errorf("Authenticated connection with "+ diff --git a/connections/authenticated/client.go b/connections/authenticated/client.go index e1d137f2e7acb436203626200ed7cbcc69235177..3026dcdf879bc14b6cdf4ccbf603b89181fea19b 100644 --- a/connections/authenticated/client.go +++ b/connections/authenticated/client.go @@ -27,6 +27,15 @@ type client interface { // clientHandler provides an implementation of the client interface. 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 // to be passed back upon establishment. connectionCallback ConnectionCallback @@ -36,35 +45,40 @@ type clientHandler struct { 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 // auth.Callbacks and receive.Listener operations. func getClient(cb ConnectionCallback, e2e clientE2e.Handler, p connect.Params) client { return clientHandler{ - connectionCallback: cb, - connectionE2e: e2e, - connectionParams: p, + clientListener: clientListener{ + connectionCallback: cb, + connectionE2e: e2e, + connectionParams: p, + }, } } // 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) { } // 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) { } // 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) { } // Hear handles the reception of an IdentityAuthentication by the // server. -func (a clientHandler) Hear(item receive.Message) { +func (a clientListener) Hear(item receive.Message) { // Process the message data into a protobuf iar := &IdentityAuthentication{} err := proto.Unmarshal(item.Payload, iar) @@ -122,6 +136,6 @@ func (a clientHandler) Hear(item receive.Message) { a.connectionParams)) } -func (a clientHandler) Name() string { +func (a clientListener) Name() string { return clientListenerName }