Commit Graph

374 Commits

Author SHA1 Message Date
Cooper Oh 23a5606d21 drop unexpected change 2024-07-19 00:43:19 +09:00
Cooper Oh d249ef1a3b use done chan for waiting pipe 2024-07-19 00:32:35 +09:00
Cooper Oh 5e557d257e add tests 2024-07-18 23:51:38 +09:00
Cooper Oh bad5b0af7f fix tls handshake on proxy 2024-07-18 23:02:07 +09:00
Cooper Oh 75fbe70bee move httpProxyDialer to newHTTPProxyDialerFunc() 2024-07-18 21:44:16 +09:00
Cooper Oh dc42337df9 move to newNetDialerFunc 2024-07-18 21:43:52 +09:00
Cooper Oh 29bba1ad6c move connection deadline set below 2024-07-18 21:34:27 +09:00
Cooper Oh bb3c912806 move proxyFromURL to client 2024-07-18 21:10:05 +09:00
Viktor Szépe 85fb2d8136 Fix typos 2024-07-15 01:15:12 +10:00
Canelo Hill 3810b2346f Handle errcheck warnings
The package ignored errors from net.Conn Set*Deadline in a few places.
Update the package to return these errors to the caller.

Ignore all other errors reported by errcheck. These errors are safe to
ignore because
- The function is making a best effort to cleanup while handling another
  error.
- The function call is guaranteed to succeed.
- The error is ignored in a test.
2024-07-06 10:12:04 +10:00
tebuka a62d9d2a84 Handle net.Error Temporary() deprecation
See https://go.dev/issue/45729.

- Remove hideTempError

  The hideTempError function was used to prevent connection methods from
  returning a net.Error with Temporary() == true.

  Connection methods do not support retry after returning any net.Error,
  including errors with Temporary() == true.

  Presumably hideTempError was used to prevent applications from
  futilely retrying connection method calls on temporary errors.

  The hideTempError function is not needed now that net.Error
  Temporary() is deprecated.

- Remove use of the deprecated net.Error Temporary() method in the
  default ping handler by ignoring all errors returned from
  WriteControl. Ignoring errors allows the application to continue
  reading messages after a write error and is consistent with how the
  default close handler calls WriteControl.
2024-07-02 22:52:06 +10:00
tebuka 682b25fffc Move doHandshake to client.go
The doHandshake function was split off to separate files to support
different implementations for Go < 1.16 and Go >= 1.17.

The separate files are not needed now that Go 1.20 is the minimum
supported version of Go for the project.
2024-07-02 22:34:31 +10:00
Canelo Hill 8915bad18b Improve bufio handling in Upgrader.Upgrade
Use Reader.Size() (add in Go 1.10) to get the bufio.Reader's size
instead of examining the return value from Reader.Peek.

Use Writer.AvailableBuffer() (added in Go 1.18) to get the
bufio.Writer's buffer instead of observing the buffer in the underlying
writer.

Allow client to send data before the handshake is complete. Previously,
Upgrader.Upgrade rudely closed the connection.
2024-07-01 13:41:19 +10:00
Halo Arrow d67f41855d Use crypto/rand for mask key 2024-07-01 13:40:25 +10:00
Thomas Massie 6426a30ef7 Return 426 status on missing upgrade header 2024-07-01 13:39:37 +10:00
Canelo Hill 1d5465562b Unbundle x/net/proxy and update to recent version
Import golang.org/x/net/proxy instead of using the bundle in
x_net_proxy.go. There's no need to avoid the dependency on
golang.org/x/net/proxy now that Go's module system is in widespread use.

Change Dialer.DialContext to pass contexts as an argument to the dial
function instead of tunneling the context through closures. Tunneling is
no longer needed because the proxy package supports contexts. The
version of the proxy package in the bundle predates contexts!

Simplify the code for calculating the base dial function.

Prevent the HTTP proxy dialer from leaking out of the websocket package
by selecting the HTTP proxy dialer directly in the websocket package.
Previously, the HTTP dialer was registered with the proxy package.
2024-06-19 20:11:25 -04:00
Canelo Hill 70bf50955e Silence false positive lint warning in proxy code 2024-06-19 17:31:46 +10:00
Konstantin Burkalev f78ed9f987 Added tests for subprotocol selection 2024-06-19 17:13:42 +10:00
Konstantin Burkalev 17f407278f Fixes subprotocol selection (aling with rfc6455) 2024-06-19 17:13:42 +10:00
mstmdev efaec3cbd1 Update README.md, replace master to main 2024-06-19 17:13:16 +10:00
Canelo Hill 688592ebe6 Improve client/server tests
Tests must not call *testing.T methods after the test function returns.
Use a sync.WaitGroup to ensure that server handler functions complete
before tests return.
2024-06-19 17:11:11 +10:00
tebuka 7e5e9b5a25 Improve hijack failure error text
Include "hijack" in text to indicate where in this package the error
occurred.
2024-06-19 17:10:25 +10:00
merlin 8890e3e578 fix: don't use errors.ErrUnsupported, it's available only since go1.21 2024-06-19 17:10:25 +10:00
merlin c7502098b0 use http.ResposnseController 2024-06-19 17:10:25 +10:00
Canelo Hill a70cea529a
Update for deprecated ioutil package (#931) 2024-06-19 14:44:41 +10:00
Canelo Hill ac1b326ac0
Set min Go version to 1.20 (#930)
Update go.mod and CI to Go version 1.20.
2024-06-19 14:40:57 +10:00
Daniel Holmes 227456c3cc chore: Retract v1.5.2 from go.mod
Maintainers accidentally changed the reference commit
for v1.5.2. This change retracts v1.5.2 which also
includes a number of avoidable issues.

Fixes #927
2024-06-19 04:30:55 +00:00
apoorvajagtap ce903f6d1d Reverts to v1.5.0
This commit reverts the changes back till 8983b96324.
And inherits the README.md changes of 931041c5ee
Relates to:
- https://github.com/gorilla/websocket/issues/880#issuecomment-2081189055
2024-06-13 23:18:03 -04:00
apoorvajagtap 9ec25ca502 fixes broken random value generation 2024-06-12 13:51:52 +05:30
apoorvajagtap 1bddf2e0db bumps go version & removes deprecated module usage 2024-05-01 18:51:54 +05:30
apoorvajagtap 750bf92096 adds GHA & Makefile configs 2024-05-01 18:51:54 +05:30
apoorvajagtap b2c246b2ec Revert " Update go version & add verification/testing tools (#840)"
This reverts commit 666c197fc9.
2024-05-01 18:51:54 +05:30
apoorvajagtap 09a6bab466 removing error handling while closing connections 2024-04-01 22:33:57 -04:00
apoorvajagtap 58af150309 return errors instead of printing to logs 2024-04-01 22:33:57 -04:00
apoorvajagtap e5f1a0aad0 excludes errchecks linter 2024-03-19 23:16:28 -04:00
Martin Greenwald b2a86a1744 Do not timeout when WriteControl deadline is zero
A zero value for the Conn.WriteControl deadline specifies no timeout,
but the feature was implemented as a very long timeout (1000 hours).
This PR updates the code to use no timeout when the deadline is zero.

See the discussion in #895 for more details.
2024-03-05 22:56:06 -05:00
Rumen Nikiforov 695e9095ce
Remove hideTempErr to allow downstream users to check for errors like net.ErrClosed (#894)
Since this change
https://github.com/gorilla/websocket/pull/840/files#diff-4f427d2b022907c552328e63f137561f6de92396d7a6e8f6c2ea1bcf0db52654L190-R197
we can no longer determinate if the errors coming from ReadMessage() are
net.ErrClosed for example
Hardcoding the error message is not great option because it may vary
from OS to OS and system locale
2024-02-15 12:59:16 +10:00
rfyiamcool d293aa53e1 feat: format message type
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
2024-02-13 23:01:06 -05:00
rfyiamcool 0cfb2cafd0 feat: format message type
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
2024-02-13 23:01:06 -05:00
rfyiamcool 316861440d fix: lint example
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
2024-02-13 22:50:58 -05:00
rfyiamcool d08ee1ad9b perf: reduce timer in write_control
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
2024-01-22 22:58:11 -05:00
rfyiamcool d15aba1e61 perf: reduce timer in write_control
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
2024-01-22 22:58:11 -05:00
Kenjiro Nakayama cf50a3efbb Revert "Print log message"
This reverts commit 6db907caed.
2024-01-21 23:02:08 -05:00
Kenjiro Nakayama 7d5b8cce7e Print log message 2024-01-21 23:02:08 -05:00
Kenjiro Nakayama 4965080703 Do not return error in SetCloseHandler 2024-01-21 23:02:08 -05:00
Kenjiro Nakayama 9a2140519a Do not handle network error in SetCloseHandler()
The 666c197 added an error handling in `SetCloseHandler()` and peer
stops getting `CloseError` when network issue like `write: broken
pipe` happens because the close handle returns the error.

Hence this patch changes to skip network error handling.
2024-01-21 23:02:08 -05:00
merlin 0f0acefeac fix: don't use errors.ErrUnsupported, it's available only since go1.21 2024-01-21 22:52:10 -05:00
merlin 1e975a03ce use http.ResposnseController 2024-01-21 22:52:10 -05:00
merlin 4a5e66f763 make tests parallel 2024-01-21 22:46:55 -05:00
Alan Xu 871f6bbc74
docs(echoreadall): fix function echoReadAll comment (#881)
As of Go 1.16, ioutil.ReadAll was deprecated.
2024-01-18 16:21:03 +10:00