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

added a closer to auth and made it called in connect on its closer

parent 514325bb
No related branches found
No related tags found
1 merge request!510Release
......@@ -16,6 +16,7 @@ import (
"gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"io"
)
type State interface {
......@@ -94,6 +95,9 @@ type State interface {
// VerifyOwnership checks if the received ownership proof is valid
VerifyOwnership(received, verified contact.Contact, e2e e2e.Handler) bool
//Closer stops listening to auth
io.Closer
}
// Callbacks is the interface for auth callback methods.
......
......@@ -119,3 +119,18 @@ func (s *state) CallAllReceivedRequests() {
func makeStorePrefix(partner *id.ID) string {
return "authStore:" + base64.StdEncoding.EncodeToString(partner.Marshal())
}
func (s *state) Close() error {
s.net.DeleteService(s.e2e.GetReceptionID(), message.Service{
Identifier: s.e2e.GetReceptionID()[:],
Tag: s.params.RequestTag,
Metadata: nil,
}, nil)
s.net.AddService(s.e2e.GetReceptionID(), message.Service{
Identifier: s.e2e.GetReceptionID()[:],
Tag: s.params.ResetRequestTag,
Metadata: nil,
}, nil)
return nil
}
......@@ -211,6 +211,7 @@ func StartServer(cb Callback, myId *id.ID, privKey *cyclic.Int,
// handler provides an implementation for the Connection interface.
type handler struct {
auth auth.State
partner partner.Manager
e2e clientE2e.Handler
params Params
......@@ -220,8 +221,9 @@ type handler struct {
// after an E2E partnership has already been confirmed with the given
// partner.Manager.
func BuildConnection(partner partner.Manager, e2eHandler clientE2e.Handler,
p Params) Connection {
auth auth.State, p Params) Connection {
return &handler{
auth: auth,
partner: partner,
params: p,
e2e: e2eHandler,
......@@ -230,7 +232,10 @@ func BuildConnection(partner partner.Manager, e2eHandler clientE2e.Handler,
// Close deletes this Connection's partner.Manager and releases resources.
func (h *handler) Close() error {
return h.e2e.DeletePartner(h.partner.PartnerId())
if err := h.e2e.DeletePartner(h.partner.PartnerId()); err != nil {
return err
}
return h.auth.Close()
}
// GetPartner returns the partner.Manager for this Connection.
......@@ -309,7 +314,7 @@ func (a authCallback) Confirm(requestor contact.Contact,
// Return the new Connection object
if a.confrimCallback != nil {
a.confrimCallback(BuildConnection(newPartner, a.connectionE2e,
a.connectionParams))
a.authState, a.connectionParams))
}
}
......@@ -341,7 +346,7 @@ func (a authCallback) Request(requestor contact.Contact,
// Return the new Connection object
a.requestCallback(BuildConnection(newPartner, a.connectionE2e,
a.connectionParams))
a.authState, a.connectionParams))
}
// Reset will be called when an auth Reset operation occurs.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment