diff --git a/conversation.go b/conversation.go index d1f863d..e38f3fb 100644 --- a/conversation.go +++ b/conversation.go @@ -29,7 +29,7 @@ type Conversation struct { maxPacketSize uint64 defaultDatagramsQueueSize uint64 streamCreator http3.StreamCreator - messageSender util.MessageSender + messageSender util.DatagramSender channelsManager *channelsManager context context.Context cancelContext context.CancelCauseFunc @@ -134,7 +134,7 @@ func (c *Conversation) EstablishClientConversation(req *http.Request, roundTripp // currently does not work for several conversations in the same QUIC connection for { - dgram, err := qconn.ReceiveMessage(c.Context()) + dgram, err := qconn.ReceiveDatagram(c.Context()) if err != nil { if err != context.Canceled { log.Error().Msgf("could not receive message from conn: %s", err) @@ -166,7 +166,7 @@ func (c *Conversation) EstablishClientConversation(req *http.Request, roundTripp } } -func NewServerConversation(ctx context.Context, controlStream http3.Stream, qconn quic.Connection, messageSender util.MessageSender, maxPacketsize uint64) (*Conversation, error) { +func NewServerConversation(ctx context.Context, controlStream http3.Stream, qconn quic.Connection, messageSender util.DatagramSender, maxPacketsize uint64) (*Conversation, error) { backgroundContext, backgroundCancelFunc := context.WithCancelCause(ctx) tls := qconn.ConnectionState().TLS @@ -290,7 +290,7 @@ func (c *Conversation) getDatagramSenderForChannel(channelID util.ChannelID) fun buf := util.AppendVarInt(nil, uint64(c.controlStream.StreamID())) buf = util.AppendVarInt(buf, channelID) buf = append(buf, datagram...) - return c.messageSender.SendMessage(buf) + return c.messageSender.SendDatagram(buf) } } diff --git a/go.mod b/go.mod index 1ab0974..229240c 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/kevinburke/ssh_config v1.2.0 github.com/onsi/ginkgo/v2 v2.13.0 github.com/onsi/gomega v1.29.0 - github.com/quic-go/quic-go v0.38.1 + github.com/quic-go/quic-go v0.40.1-0.20240102075208-1083d1fb8f98 github.com/rs/zerolog v1.31.0 golang.org/x/crypto v0.14.0 golang.org/x/oauth2 v0.13.0 @@ -27,6 +27,7 @@ require ( github.com/mattn/go-isatty v0.0.19 // indirect github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/qtls-go1-20 v0.3.3 // indirect + go.uber.org/mock v0.3.0 // indirect golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.17.0 // indirect diff --git a/go.sum b/go.sum index 877e79b..8c0c890 100644 --- a/go.sum +++ b/go.sum @@ -57,6 +57,8 @@ github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eU github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE= github.com/quic-go/quic-go v0.38.1/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= +github.com/quic-go/quic-go v0.40.1-0.20240102075208-1083d1fb8f98 h1:XSdekoU+UVlq/Mav+6dYyPuyy5+qzDa/TglBVi+L7Rs= +github.com/quic-go/quic-go v0.40.1-0.20240102075208-1083d1fb8f98/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= @@ -68,6 +70,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= +go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= diff --git a/server.go b/server.go index f9b088e..679ee3e 100644 --- a/server.go +++ b/server.go @@ -147,7 +147,7 @@ func (s *Server) GetHTTPHandlerFunc(ctx context.Context) AuthenticatedHandlerFun // TODO: this hijacks the datagrams for the whole quic connection, so the server // currently does not work for several conversations in the same QUIC connection for { - dgram, err := qconn.ReceiveMessage(ctx) + dgram, err := qconn.ReceiveDatagram(ctx) if err != nil { if !errors.Is(err, context.Canceled) && !errors.Is(err, net.ErrClosed) { log.Error().Msgf("could not receive message from conn: %s", err) diff --git a/util/types.go b/util/types.go index 1f410a8..7af5f0b 100644 --- a/util/types.go +++ b/util/types.go @@ -64,6 +64,6 @@ func (b *BytesReadCloser) Close() error { return nil } // sends an ssh3 datagram. The function must know the ID of the channel type SSH3DatagramSenderFunc func(p []byte) error -type MessageSender interface { - SendMessage(p []byte) error +type DatagramSender interface { + SendDatagram(p []byte) error }