Commit 04d0a895 authored by David Stainton's avatar David Stainton

Flatten hierarchy, eradicate session module

parent 1dc6e4ba
Pipeline #990 passed with stage
in 7 minutes and 24 seconds
......@@ -30,7 +30,6 @@ import (
"github.com/katzenpost/client/config"
clientConfig "github.com/katzenpost/client/config"
"github.com/katzenpost/client/session"
"github.com/katzenpost/core/crypto/ecdh"
"github.com/katzenpost/core/crypto/rand"
"github.com/katzenpost/core/epochtime"
......@@ -128,7 +127,7 @@ type Client struct {
haltedCh chan interface{}
haltOnce *sync.Once
session *session.Session
session *Session
}
func (c *Client) Provider() string {
......@@ -180,12 +179,12 @@ func (c *Client) halt() {
}
// NewSession creates and returns a new session or an error.
func (c *Client) NewSession(linkKey *ecdh.PrivateKey) (*session.Session, error) {
func (c *Client) NewSession(linkKey *ecdh.PrivateKey) (*Session, error) {
var err error
timeout := time.Duration(c.cfg.Debug.SessionDialTimeout) * time.Second
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
c.session, err = session.New(ctx, c.fatalErrCh, c.logBackend, c.cfg, linkKey)
c.session, err = NewSession(ctx, c.fatalErrCh, c.logBackend, c.cfg, linkKey)
return c.session, err
}
......
......@@ -24,7 +24,6 @@ import (
"testing"
"github.com/katzenpost/client/config"
"github.com/katzenpost/client/session"
"github.com/katzenpost/core/utils"
"github.com/stretchr/testify/require"
)
......@@ -122,12 +121,12 @@ func TestDockerClientAsyncSendReceive(t *testing.T) {
go func() {
for eventRaw := range clientSession.EventSink {
switch event := eventRaw.(type) {
case *session.MessageSentEvent:
case *MessageSentEvent:
if bytes.Equal(msgID[:], event.MessageID[:]) {
require.NoError(event.Err)
wg.Done()
}
case *session.MessageReplyEvent:
case *MessageReplyEvent:
if bytes.Equal(msgID[:], event.MessageID[:]) {
require.NoError(event.Err)
require.True(utils.CtIsZero(event.Payload))
......@@ -171,12 +170,12 @@ func TestDockerClientAsyncSendReceiveWithDecoyTraffic(t *testing.T) {
go func() {
for eventRaw := range clientSession.EventSink {
switch event := eventRaw.(type) {
case *session.MessageSentEvent:
case *MessageSentEvent:
if bytes.Equal(msgID[:], event.MessageID[:]) {
require.NoError(event.Err)
wg.Done()
}
case *session.MessageReplyEvent:
case *MessageReplyEvent:
if bytes.Equal(msgID[:], event.MessageID[:]) {
require.NoError(event.Err)
require.True(utils.CtIsZero(event.Payload))
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package session
package client
import (
"encoding/hex"
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package session
package client
import (
"time"
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package session
package client
import (
"errors"
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package session
package client
import (
"encoding/binary"
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package session
package client
import (
"context"
......@@ -78,7 +78,7 @@ type Session struct {
// New establishes a session with provider using key.
// This method will block until session is connected to the Provider.
func New(ctx context.Context, fatalErrCh chan error, logBackend *log.Backend, cfg *config.Config, linkKey *ecdh.PrivateKey) (*Session, error) {
func NewSession(ctx context.Context, fatalErrCh chan error, logBackend *log.Backend, cfg *config.Config, linkKey *ecdh.PrivateKey) (*Session, error) {
var err error
// create a pkiclient for our own client lookups
......
// timerq.go - Time delayed queue
// timer_queue.go - Time delayed queue
// Copyright (C) 2018, 2019 Masala, David Stainton.
//
// This program is free software: you can redistribute it and/or modify
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package session
package client
import (
"fmt"
......
// timerq_test.go - Time delayed queue tests
// timer_queue_test.go - Time delayed queue tests
// Copyright (C) 2018 Masala, David Stainton.
//
// This program is free software: you can redistribute it and/or modify
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package session
package client
import (
"io"
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package session
package client
import (
"errors"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment