From 95b087c0595227ed2134c5cfbe56b8005db3d6e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:06:01 +0000 Subject: [PATCH] chore: bump nhooyr.io/websocket from 1.8.11 to 1.8.17 Bumps [nhooyr.io/websocket](https://github.com/nhooyr/websocket-old) from 1.8.11 to 1.8.17. - [Release notes](https://github.com/nhooyr/websocket-old/releases) - [Commits](https://github.com/nhooyr/websocket-old/commits/v1.8.17) --- updated-dependencies: - dependency-name: nhooyr.io/websocket dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- vendor/modules.txt | 2 +- vendor/nhooyr.io/websocket/README.md | 156 +------------------------ vendor/nhooyr.io/websocket/accept.go | 4 + vendor/nhooyr.io/websocket/close.go | 11 ++ vendor/nhooyr.io/websocket/compress.go | 2 + vendor/nhooyr.io/websocket/conn.go | 8 ++ vendor/nhooyr.io/websocket/dial.go | 4 + vendor/nhooyr.io/websocket/doc.go | 2 + vendor/nhooyr.io/websocket/netconn.go | 2 + vendor/nhooyr.io/websocket/read.go | 8 ++ vendor/nhooyr.io/websocket/stringer.go | 2 + vendor/nhooyr.io/websocket/write.go | 4 + 14 files changed, 52 insertions(+), 159 deletions(-) diff --git a/go.mod b/go.mod index 1f3b4f1..aa5684e 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/urfave/cli/v2 v2.27.1 github.com/vmihailenco/msgpack/v5 v5.4.1 golang.org/x/sys v0.21.0 - nhooyr.io/websocket v1.8.11 + nhooyr.io/websocket v1.8.17 ) require ( diff --git a/go.sum b/go.sum index 56d3e19..cb7e345 100644 --- a/go.sum +++ b/go.sum @@ -45,5 +45,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0= -nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= +nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y= +nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= diff --git a/vendor/modules.txt b/vendor/modules.txt index 3cd6751..f604faf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -52,7 +52,7 @@ golang.org/x/sys/windows # gopkg.in/yaml.v3 v3.0.1 ## explicit gopkg.in/yaml.v3 -# nhooyr.io/websocket v1.8.11 +# nhooyr.io/websocket v1.8.17 ## explicit; go 1.19 nhooyr.io/websocket nhooyr.io/websocket/internal/bpool diff --git a/vendor/nhooyr.io/websocket/README.md b/vendor/nhooyr.io/websocket/README.md index d093746..d663d5d 100644 --- a/vendor/nhooyr.io/websocket/README.md +++ b/vendor/nhooyr.io/websocket/README.md @@ -1,155 +1 @@ -# websocket - -[![Go Reference](https://pkg.go.dev/badge/nhooyr.io/websocket.svg)](https://pkg.go.dev/nhooyr.io/websocket) -[![Go Coverage](https://img.shields.io/badge/coverage-91%25-success)](https://nhooyr.io/websocket/coverage.html) - -websocket is a minimal and idiomatic WebSocket library for Go. - -## Install - -```sh -go get nhooyr.io/websocket -``` - -## Highlights - -- Minimal and idiomatic API -- First class [context.Context](https://blog.golang.org/context) support -- Fully passes the WebSocket [autobahn-testsuite](https://github.com/crossbario/autobahn-testsuite) -- [Zero dependencies](https://pkg.go.dev/nhooyr.io/websocket?tab=imports) -- JSON helpers in the [wsjson](https://pkg.go.dev/nhooyr.io/websocket/wsjson) subpackage -- Zero alloc reads and writes -- Concurrent writes -- [Close handshake](https://pkg.go.dev/nhooyr.io/websocket#Conn.Close) -- [net.Conn](https://pkg.go.dev/nhooyr.io/websocket#NetConn) wrapper -- [Ping pong](https://pkg.go.dev/nhooyr.io/websocket#Conn.Ping) API -- [RFC 7692](https://tools.ietf.org/html/rfc7692) permessage-deflate compression -- [CloseRead](https://pkg.go.dev/nhooyr.io/websocket#Conn.CloseRead) helper for write only connections -- Compile to [Wasm](https://pkg.go.dev/nhooyr.io/websocket#hdr-Wasm) - -## Roadmap - -See GitHub issues for minor issues but the major future enhancements are: - -- [ ] Perfect examples [#217](https://github.com/nhooyr/websocket/issues/217) -- [ ] wstest.Pipe for in memory testing [#340](https://github.com/nhooyr/websocket/issues/340) -- [ ] Ping pong heartbeat helper [#267](https://github.com/nhooyr/websocket/issues/267) -- [ ] Ping pong instrumentation callbacks [#246](https://github.com/nhooyr/websocket/issues/246) -- [ ] Graceful shutdown helpers [#209](https://github.com/nhooyr/websocket/issues/209) -- [ ] Assembly for WebSocket masking [#16](https://github.com/nhooyr/websocket/issues/16) - - WIP at [#326](https://github.com/nhooyr/websocket/pull/326), about 3x faster -- [ ] HTTP/2 [#4](https://github.com/nhooyr/websocket/issues/4) -- [ ] The holy grail [#402](https://github.com/nhooyr/websocket/issues/402) - -## Examples - -For a production quality example that demonstrates the complete API, see the -[echo example](./internal/examples/echo). - -For a full stack example, see the [chat example](./internal/examples/chat). - -### Server - -```go -http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) { - c, err := websocket.Accept(w, r, nil) - if err != nil { - // ... - } - defer c.CloseNow() - - ctx, cancel := context.WithTimeout(r.Context(), time.Second*10) - defer cancel() - - var v interface{} - err = wsjson.Read(ctx, c, &v) - if err != nil { - // ... - } - - log.Printf("received: %v", v) - - c.Close(websocket.StatusNormalClosure, "") -}) -``` - -### Client - -```go -ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -defer cancel() - -c, _, err := websocket.Dial(ctx, "ws://localhost:8080", nil) -if err != nil { - // ... -} -defer c.CloseNow() - -err = wsjson.Write(ctx, c, "hi") -if err != nil { - // ... -} - -c.Close(websocket.StatusNormalClosure, "") -``` - -## Comparison - -### gorilla/websocket - -Advantages of [gorilla/websocket](https://github.com/gorilla/websocket): - -- Mature and widely used -- [Prepared writes](https://pkg.go.dev/github.com/gorilla/websocket#PreparedMessage) -- Configurable [buffer sizes](https://pkg.go.dev/github.com/gorilla/websocket#hdr-Buffers) -- No extra goroutine per connection to support cancellation with context.Context. This costs nhooyr.io/websocket 2 KB of memory per connection. - - Will be removed soon with [context.AfterFunc](https://github.com/golang/go/issues/57928). See [#411](https://github.com/nhooyr/websocket/issues/411) - -Advantages of nhooyr.io/websocket: - -- Minimal and idiomatic API - - Compare godoc of [nhooyr.io/websocket](https://pkg.go.dev/nhooyr.io/websocket) with [gorilla/websocket](https://pkg.go.dev/github.com/gorilla/websocket) side by side. -- [net.Conn](https://pkg.go.dev/nhooyr.io/websocket#NetConn) wrapper -- Zero alloc reads and writes ([gorilla/websocket#535](https://github.com/gorilla/websocket/issues/535)) -- Full [context.Context](https://blog.golang.org/context) support -- Dial uses [net/http.Client](https://golang.org/pkg/net/http/#Client) - - Will enable easy HTTP/2 support in the future - - Gorilla writes directly to a net.Conn and so duplicates features of net/http.Client. -- Concurrent writes -- Close handshake ([gorilla/websocket#448](https://github.com/gorilla/websocket/issues/448)) -- Idiomatic [ping pong](https://pkg.go.dev/nhooyr.io/websocket#Conn.Ping) API - - Gorilla requires registering a pong callback before sending a Ping -- Can target Wasm ([gorilla/websocket#432](https://github.com/gorilla/websocket/issues/432)) -- Transparent message buffer reuse with [wsjson](https://pkg.go.dev/nhooyr.io/websocket/wsjson) subpackage -- [1.75x](https://github.com/nhooyr/websocket/releases/tag/v1.7.4) faster WebSocket masking implementation in pure Go - - Gorilla's implementation is slower and uses [unsafe](https://golang.org/pkg/unsafe/). - Soon we'll have assembly and be 3x faster [#326](https://github.com/nhooyr/websocket/pull/326) -- Full [permessage-deflate](https://tools.ietf.org/html/rfc7692) compression extension support - - Gorilla only supports no context takeover mode -- [CloseRead](https://pkg.go.dev/nhooyr.io/websocket#Conn.CloseRead) helper for write only connections ([gorilla/websocket#492](https://github.com/gorilla/websocket/issues/492)) - -#### golang.org/x/net/websocket - -[golang.org/x/net/websocket](https://pkg.go.dev/golang.org/x/net/websocket) is deprecated. -See [golang/go/issues/18152](https://github.com/golang/go/issues/18152). - -The [net.Conn](https://pkg.go.dev/nhooyr.io/websocket#NetConn) can help in transitioning -to nhooyr.io/websocket. - -#### gobwas/ws - -[gobwas/ws](https://github.com/gobwas/ws) has an extremely flexible API that allows it to be used -in an event driven style for performance. See the author's [blog post](https://medium.freecodecamp.org/million-websockets-and-go-cc58418460bb). - -However it is quite bloated. See https://pkg.go.dev/github.com/gobwas/ws - -When writing idiomatic Go, nhooyr.io/websocket will be faster and easier to use. - -#### lesismal/nbio - -[lesismal/nbio](https://github.com/lesismal/nbio) is similar to gobwas/ws in that the API is -event driven for performance reasons. - -However it is quite bloated. See https://pkg.go.dev/github.com/lesismal/nbio - -When writing idiomatic Go, nhooyr.io/websocket will be faster and easier to use. +deprecated: Use https://github.com/coder/websocket instead diff --git a/vendor/nhooyr.io/websocket/accept.go b/vendor/nhooyr.io/websocket/accept.go index 285b310..e1fd1f4 100644 --- a/vendor/nhooyr.io/websocket/accept.go +++ b/vendor/nhooyr.io/websocket/accept.go @@ -21,6 +21,8 @@ import ( ) // AcceptOptions represents Accept's options. +// +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. type AcceptOptions struct { // Subprotocols lists the WebSocket subprotocols that Accept will negotiate with the client. // The empty subprotocol will always be negotiated as per RFC 6455. If you would like to @@ -75,6 +77,8 @@ func (opts *AcceptOptions) cloneWithDefaults() *AcceptOptions { // Accept accepts a WebSocket handshake from a client and upgrades the // the connection to a WebSocket. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // Accept will not allow cross origin requests by default. // See the InsecureSkipVerify and OriginPatterns options to allow cross origin requests. // diff --git a/vendor/nhooyr.io/websocket/close.go b/vendor/nhooyr.io/websocket/close.go index 31504b0..efbc203 100644 --- a/vendor/nhooyr.io/websocket/close.go +++ b/vendor/nhooyr.io/websocket/close.go @@ -16,6 +16,8 @@ import ( // StatusCode represents a WebSocket status code. // https://tools.ietf.org/html/rfc6455#section-7.4 +// +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. type StatusCode int // https://www.iana.org/assignments/websocket/websocket.xhtml#close-code-number @@ -61,6 +63,8 @@ const ( // CloseError is returned when the connection is closed with a status and reason. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // Use Go 1.13's errors.As to check for this error. // Also see the CloseStatus helper. type CloseError struct { @@ -68,6 +72,7 @@ type CloseError struct { Reason string } +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. func (ce CloseError) Error() string { return fmt.Sprintf("status = %v and reason = %q", ce.Code, ce.Reason) } @@ -75,6 +80,8 @@ func (ce CloseError) Error() string { // CloseStatus is a convenience wrapper around Go 1.13's errors.As to grab // the status code from a CloseError. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // -1 will be returned if the passed error is nil or not a CloseError. func CloseStatus(err error) StatusCode { var ce CloseError @@ -86,6 +93,8 @@ func CloseStatus(err error) StatusCode { // Close performs the WebSocket close handshake with the given status code and reason. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // It will write a WebSocket close frame with a timeout of 5s and then wait 5s for // the peer to send a close frame. // All data messages received from the peer during the close handshake will be discarded. @@ -130,6 +139,8 @@ func (c *Conn) Close(code StatusCode, reason string) (err error) { // CloseNow closes the WebSocket connection without attempting a close handshake. // Use when you do not want the overhead of the close handshake. +// +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. func (c *Conn) CloseNow() (err error) { defer errd.Wrap(&err, "failed to immediately close WebSocket") diff --git a/vendor/nhooyr.io/websocket/compress.go b/vendor/nhooyr.io/websocket/compress.go index 1f3adcf..e50ae0b 100644 --- a/vendor/nhooyr.io/websocket/compress.go +++ b/vendor/nhooyr.io/websocket/compress.go @@ -12,6 +12,8 @@ import ( // CompressionMode represents the modes available to the permessage-deflate extension. // See https://tools.ietf.org/html/rfc7692 // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // Works in all modern browsers except Safari which does not implement the permessage-deflate extension. // // Compression is only used if the peer supports the mode selected. diff --git a/vendor/nhooyr.io/websocket/conn.go b/vendor/nhooyr.io/websocket/conn.go index 8690fb3..2bf221c 100644 --- a/vendor/nhooyr.io/websocket/conn.go +++ b/vendor/nhooyr.io/websocket/conn.go @@ -17,6 +17,8 @@ import ( // MessageType represents the type of a WebSocket message. // See https://tools.ietf.org/html/rfc6455#section-5.6 +// +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. type MessageType int // MessageType constants. @@ -30,6 +32,8 @@ const ( // Conn represents a WebSocket connection. // All methods may be called concurrently except for Reader and Read. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // You must always read from the connection. Otherwise control // frames will not be handled. See Reader and CloseRead. // @@ -140,6 +144,8 @@ func newConn(cfg connConfig) *Conn { // Subprotocol returns the negotiated subprotocol. // An empty string means the default protocol. +// +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. func (c *Conn) Subprotocol() string { return c.subprotocol } @@ -198,6 +204,8 @@ func (c *Conn) flate() bool { // not read from the connection but instead waits for a Reader call // to read the pong. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // TCP Keepalives should suffice for most use cases. func (c *Conn) Ping(ctx context.Context) error { p := atomic.AddInt32(&c.pingCounter, 1) diff --git a/vendor/nhooyr.io/websocket/dial.go b/vendor/nhooyr.io/websocket/dial.go index e4c4daa..6dd8050 100644 --- a/vendor/nhooyr.io/websocket/dial.go +++ b/vendor/nhooyr.io/websocket/dial.go @@ -21,6 +21,8 @@ import ( ) // DialOptions represents Dial's options. +// +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. type DialOptions struct { // HTTPClient is used for the connection. // Its Transport must return writable bodies for WebSocket handshakes. @@ -91,6 +93,8 @@ func (opts *DialOptions) cloneWithDefaults(ctx context.Context) (context.Context // Dial performs a WebSocket handshake on url. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // The response is the WebSocket handshake response from the server. // You never need to close resp.Body yourself. // diff --git a/vendor/nhooyr.io/websocket/doc.go b/vendor/nhooyr.io/websocket/doc.go index 2ab648a..0d8e66a 100644 --- a/vendor/nhooyr.io/websocket/doc.go +++ b/vendor/nhooyr.io/websocket/doc.go @@ -3,6 +3,8 @@ // Package websocket implements the RFC 6455 WebSocket protocol. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // https://tools.ietf.org/html/rfc6455 // // Use Dial to dial a WebSocket server. diff --git a/vendor/nhooyr.io/websocket/netconn.go b/vendor/nhooyr.io/websocket/netconn.go index 86f7dad..9359bbc 100644 --- a/vendor/nhooyr.io/websocket/netconn.go +++ b/vendor/nhooyr.io/websocket/netconn.go @@ -12,6 +12,8 @@ import ( // NetConn converts a *websocket.Conn into a net.Conn. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // It's for tunneling arbitrary protocols over WebSockets. // Few users of the library will need this but it's tricky to implement // correctly and so provided in the library. diff --git a/vendor/nhooyr.io/websocket/read.go b/vendor/nhooyr.io/websocket/read.go index a59e71d..6ea2d50 100644 --- a/vendor/nhooyr.io/websocket/read.go +++ b/vendor/nhooyr.io/websocket/read.go @@ -21,6 +21,8 @@ import ( // Reader reads from the connection until there is a WebSocket // data message to be read. It will handle ping, pong and close frames as appropriate. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // It returns the type of the message and an io.Reader to read it. // The passed context will also bound the reader. // Ensure you read to EOF otherwise the connection will hang. @@ -39,6 +41,8 @@ func (c *Conn) Reader(ctx context.Context) (MessageType, io.Reader, error) { // Read is a convenience method around Reader to read a single message // from the connection. +// +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) { typ, r, err := c.Reader(ctx) if err != nil { @@ -52,6 +56,8 @@ func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) { // CloseRead starts a goroutine to read from the connection until it is closed // or a data message is received. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // Once CloseRead is called you cannot read any messages from the connection. // The returned context will be cancelled when the connection is closed. // @@ -89,6 +95,8 @@ func (c *Conn) CloseRead(ctx context.Context) context.Context { // SetReadLimit sets the max number of bytes to read for a single message. // It applies to the Reader and Read methods. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // By default, the connection has a message read limit of 32768 bytes. // // When the limit is hit, the connection will be closed with StatusMessageTooBig. diff --git a/vendor/nhooyr.io/websocket/stringer.go b/vendor/nhooyr.io/websocket/stringer.go index 5a66ba2..f70b623 100644 --- a/vendor/nhooyr.io/websocket/stringer.go +++ b/vendor/nhooyr.io/websocket/stringer.go @@ -49,6 +49,7 @@ const _MessageType_name = "MessageTextMessageBinary" var _MessageType_index = [...]uint8{0, 11, 24} +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. func (i MessageType) String() string { i -= 1 if i < 0 || i >= MessageType(len(_MessageType_index)-1) { @@ -82,6 +83,7 @@ const _StatusCode_name = "StatusNormalClosureStatusGoingAwayStatusProtocolErrorS var _StatusCode_index = [...]uint16{0, 19, 34, 53, 74, 88, 106, 127, 156, 177, 196, 220, 239, 259, 278, 294, 312} +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. func (i StatusCode) String() string { i -= 1000 if i < 0 || i >= StatusCode(len(_StatusCode_index)-1) { diff --git a/vendor/nhooyr.io/websocket/write.go b/vendor/nhooyr.io/websocket/write.go index d7222f2..6eaecad 100644 --- a/vendor/nhooyr.io/websocket/write.go +++ b/vendor/nhooyr.io/websocket/write.go @@ -23,6 +23,8 @@ import ( // Writer returns a writer bounded by the context that will write // a WebSocket message of type dataType to the connection. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // You must close the writer once you have written the entire message. // // Only one writer can be open at a time, multiple calls will block until the previous writer @@ -37,6 +39,8 @@ func (c *Conn) Writer(ctx context.Context, typ MessageType) (io.WriteCloser, err // Write writes a message to the connection. // +// Deprecated: coder now maintains this library at https://github.com/coder/websocket. +// // See the Writer method if you want to stream a message. // // If compression is disabled or the compression threshold is not met, then it