Skip to content

Commit

Permalink
cleanup: backend package names
Browse files Browse the repository at this point in the history
  • Loading branch information
parvit committed Sep 22, 2024
1 parent 2e46a75 commit 243723b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions backend/backend_quicgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"fmt"
"github.com/Project-Faster/quic-go"
"github.com/Project-Faster/quic-go/logging"
errors2 "github.com/parvit/qpep/shared/errors"
stderr "github.com/parvit/qpep/shared/errors"
"github.com/parvit/qpep/shared/logger"
"github.com/parvit/qpep/workers/gateway"
"io/ioutil"
Expand Down Expand Up @@ -53,7 +53,7 @@ func (q *quicGoBackend) Dial(ctx context.Context, remoteAddress string, port int
session, err = quic.DialAddr(gatewayPath, tlsConf, quicConfig)
if err != nil {
logger.Error("Unable to Dial Protocol Session: %v\n", err)
return nil, errors2.ErrFailedGatewayConnect
return nil, stderr.ErrFailedGatewayConnect
}

sessionAdapter := &qgoConnectionAdapter{
Expand All @@ -73,7 +73,7 @@ func (q *quicGoBackend) Listen(ctx context.Context, address string, port int, se
conn, err := quic.ListenAddr(fmt.Sprintf("%s:%d", address, port), tlsConf, quicConfig)
if err != nil {
logger.Error("Failed to listen on Protocol session: %v\n", err)
return nil, errors2.ErrFailedGatewayConnect
return nil, stderr.ErrFailedGatewayConnect
}

return &qgoConnectionAdapter{
Expand Down Expand Up @@ -126,7 +126,7 @@ func (c *qgoConnectionAdapter) LocalAddr() net.Addr {
if c.listener != nil {
return c.listener.Addr()
}
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *qgoConnectionAdapter) RemoteAddr() net.Addr {
Expand All @@ -136,7 +136,7 @@ func (c *qgoConnectionAdapter) RemoteAddr() net.Addr {
if c.listener != nil {
return c.listener.Addr()
}
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *qgoConnectionAdapter) AcceptConnection(ctx context.Context) (QuicBackendConnection, error) {
Expand All @@ -153,7 +153,7 @@ func (c *qgoConnectionAdapter) AcceptConnection(ctx context.Context) (QuicBacken
}
return cNew, nil
}
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *qgoConnectionAdapter) AcceptStream(ctx context.Context) (QuicBackendStream, error) {
Expand All @@ -166,7 +166,7 @@ func (c *qgoConnectionAdapter) AcceptStream(ctx context.Context) (QuicBackendStr
Stream: stream,
}, err
}
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *qgoConnectionAdapter) OpenStream(ctx context.Context) (QuicBackendStream, error) {
Expand All @@ -176,7 +176,7 @@ func (c *qgoConnectionAdapter) OpenStream(ctx context.Context) (QuicBackendStrea
Stream: stream,
}, err
}
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *qgoConnectionAdapter) Close(code int, message string) error {
Expand Down
28 changes: 14 additions & 14 deletions backend/backend_quiclygo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/Project-Faster/quicly-go"
"github.com/Project-Faster/quicly-go/quiclylib/errors"
"github.com/Project-Faster/quicly-go/quiclylib/types"
errors2 "github.com/parvit/qpep/shared/errors"
stderr "github.com/parvit/qpep/shared/errors"
"github.com/parvit/qpep/shared/logger"
"net"
"os"
Expand Down Expand Up @@ -80,7 +80,7 @@ func (q *quiclyGoBackend) init(isClient, traceOn bool, certPath, certKeyPath, cc
}

if err := quicly.Initialize(quicConfig); err != errors.QUICLY_OK {
return errors2.ErrFailed
return stderr.ErrFailed
}
q.initialized = true

Expand Down Expand Up @@ -131,7 +131,7 @@ func (q *quiclyGoBackend) Dial(ctx context.Context, remoteAddress string, port i
if session == nil {
logger.Error("Unable to Dial Protocol Session\n")
q.opLock.Unlock()
return nil, errors2.ErrFailedGatewayConnect
return nil, stderr.ErrFailedGatewayConnect
}

sessionAdapter := &cliConnectionAdapter{
Expand Down Expand Up @@ -186,7 +186,7 @@ func (q *quiclyGoBackend) Listen(ctx context.Context, address string, port int,
func (q *quiclyGoBackend) Close() error {
if !q.initialized {
logger.Error("Protocol was not initialized")
return errors2.ErrFailed
return stderr.ErrFailed
}
q.opLock.Lock()
defer q.opLock.Unlock()
Expand Down Expand Up @@ -232,15 +232,15 @@ func (c *srvListenerAdapter) AcceptConnection(ctx context.Context) (QuicBackendC
connection: conn,
}, nil
}
return nil, errors2.ErrInvalidBackendOperation
return nil, stderr.ErrInvalidBackendOperation
}

func (c *srvListenerAdapter) AcceptStream(ctx context.Context) (QuicBackendStream, error) {
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *srvListenerAdapter) OpenStream(ctx context.Context) (QuicBackendStream, error) {
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *srvListenerAdapter) Close(code int, message string) error {
Expand Down Expand Up @@ -280,7 +280,7 @@ func (c *srvConnectionAdapter) RemoteAddr() net.Addr {
}

func (c *srvConnectionAdapter) AcceptConnection(ctx context.Context) (QuicBackendConnection, error) {
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *srvConnectionAdapter) AcceptStream(ctx context.Context) (QuicBackendStream, error) {
Expand All @@ -295,11 +295,11 @@ func (c *srvConnectionAdapter) AcceptStream(ctx context.Context) (QuicBackendStr
id: stream.ID(),
}, err
}
return nil, errors2.ErrInvalidBackendOperation
return nil, stderr.ErrInvalidBackendOperation
}

func (c *srvConnectionAdapter) OpenStream(ctx context.Context) (QuicBackendStream, error) {
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *srvConnectionAdapter) Close(code int, message string) error {
Expand Down Expand Up @@ -341,11 +341,11 @@ func (c *cliConnectionAdapter) RemoteAddr() net.Addr {
}

func (c *cliConnectionAdapter) AcceptStream(ctx context.Context) (QuicBackendStream, error) {
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *cliConnectionAdapter) AcceptConnection(ctx context.Context) (QuicBackendConnection, error) {
panic(errors2.ErrInvalidBackendOperation)
panic(stderr.ErrInvalidBackendOperation)
}

func (c *cliConnectionAdapter) Close(code int, message string) error {
Expand All @@ -362,7 +362,7 @@ func (c *cliConnectionAdapter) OpenStream(ctx context.Context) (QuicBackendStrea
if c.connection != nil {
stream := c.connection.OpenStream()
if stream == nil {
return nil, errors2.ErrFailed
return nil, stderr.ErrFailed
}

return &streamAdapter{
Expand All @@ -371,7 +371,7 @@ func (c *cliConnectionAdapter) OpenStream(ctx context.Context) (QuicBackendStrea
id: stream.ID(),
}, nil
}
return nil, errors2.ErrFailed
return nil, stderr.ErrFailed
}

func (c *cliConnectionAdapter) IsClosed() bool {
Expand Down

0 comments on commit 243723b

Please sign in to comment.