Skip to content
Snippets Groups Projects
Commit 25c82d18 authored by Jake Taylor's avatar Jake Taylor
Browse files

Merge remote-tracking branch 'origin/release' into release

parents c2e995b8 210191fa
No related branches found
No related tags found
1 merge request!510Release
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/id/ephemeral"
"io"
) )
type State interface { type State interface {
...@@ -94,6 +95,9 @@ type State interface { ...@@ -94,6 +95,9 @@ type State interface {
// VerifyOwnership checks if the received ownership proof is valid // VerifyOwnership checks if the received ownership proof is valid
VerifyOwnership(received, verified contact.Contact, e2e e2e.Handler) bool VerifyOwnership(received, verified contact.Contact, e2e e2e.Handler) bool
//Closer stops listening to auth
io.Closer
} }
// Callbacks is the interface for auth callback methods. // Callbacks is the interface for auth callback methods.
......
...@@ -119,3 +119,18 @@ func (s *state) CallAllReceivedRequests() { ...@@ -119,3 +119,18 @@ func (s *state) CallAllReceivedRequests() {
func makeStorePrefix(partner *id.ID) string { func makeStorePrefix(partner *id.ID) string {
return "authStore:" + base64.StdEncoding.EncodeToString(partner.Marshal()) 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
}
...@@ -85,8 +85,8 @@ func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) { ...@@ -85,8 +85,8 @@ func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) {
} }
// Close deletes this Connection's partner.Manager and releases resources // Close deletes this Connection's partner.Manager and releases resources
func (c *Connection) Close() { func (c *Connection) Close() error {
c.Close() return c.connection.Close()
} }
// GetPartner returns the partner.Manager for this Connection // GetPartner returns the partner.Manager for this Connection
......
...@@ -94,8 +94,8 @@ type Params struct { ...@@ -94,8 +94,8 @@ type Params struct {
// GetDefaultParams returns a usable set of default Connection parameters. // GetDefaultParams returns a usable set of default Connection parameters.
func GetDefaultParams() Params { func GetDefaultParams() Params {
return Params{ return Params{
Auth: auth.GetDefaultParams(), Auth: auth.GetDefaultTemporaryParams(),
Rekey: rekey.GetDefaultParams(), Rekey: rekey.GetDefaultEphemeralParams(),
Event: event.NewEventManager(), Event: event.NewEventManager(),
Timeout: connectionTimeout, Timeout: connectionTimeout,
} }
...@@ -211,6 +211,7 @@ func StartServer(cb Callback, myId *id.ID, privKey *cyclic.Int, ...@@ -211,6 +211,7 @@ func StartServer(cb Callback, myId *id.ID, privKey *cyclic.Int,
// handler provides an implementation for the Connection interface. // handler provides an implementation for the Connection interface.
type handler struct { type handler struct {
auth auth.State
partner partner.Manager partner partner.Manager
e2e clientE2e.Handler e2e clientE2e.Handler
params Params params Params
...@@ -220,8 +221,9 @@ type handler struct { ...@@ -220,8 +221,9 @@ type handler struct {
// after an E2E partnership has already been confirmed with the given // after an E2E partnership has already been confirmed with the given
// partner.Manager. // partner.Manager.
func BuildConnection(partner partner.Manager, e2eHandler clientE2e.Handler, func BuildConnection(partner partner.Manager, e2eHandler clientE2e.Handler,
p Params) Connection { auth auth.State, p Params) Connection {
return &handler{ return &handler{
auth: auth,
partner: partner, partner: partner,
params: p, params: p,
e2e: e2eHandler, e2e: e2eHandler,
...@@ -230,7 +232,10 @@ func BuildConnection(partner partner.Manager, e2eHandler clientE2e.Handler, ...@@ -230,7 +232,10 @@ func BuildConnection(partner partner.Manager, e2eHandler clientE2e.Handler,
// Close deletes this Connection's partner.Manager and releases resources. // Close deletes this Connection's partner.Manager and releases resources.
func (h *handler) Close() error { 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. // GetPartner returns the partner.Manager for this Connection.
...@@ -309,7 +314,7 @@ func (a authCallback) Confirm(requestor contact.Contact, ...@@ -309,7 +314,7 @@ func (a authCallback) Confirm(requestor contact.Contact,
// Return the new Connection object // Return the new Connection object
if a.confrimCallback != nil { if a.confrimCallback != nil {
a.confrimCallback(BuildConnection(newPartner, a.connectionE2e, a.confrimCallback(BuildConnection(newPartner, a.connectionE2e,
a.connectionParams)) a.authState, a.connectionParams))
} }
} }
...@@ -341,7 +346,7 @@ func (a authCallback) Request(requestor contact.Contact, ...@@ -341,7 +346,7 @@ func (a authCallback) Request(requestor contact.Contact,
// Return the new Connection object // Return the new Connection object
a.requestCallback(BuildConnection(newPartner, a.connectionE2e, a.requestCallback(BuildConnection(newPartner, a.connectionE2e,
a.connectionParams)) a.authState, a.connectionParams))
} }
// Reset will be called when an auth Reset operation occurs. // 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.
Finish editing this message first!
Please register or to comment