The methods didn't have pointer receivers. Thus the deadline fields
were only updated for the local variable.
Closes: https://todo.sr.ht/~emersion/soju/106
... by replacing invalid bytes with the REPLACEMENT CHARACTER U+FFFD
This is better than:
- discarding the whole message, since the user would not see it...
- removing invalid bytes, since the user would not see their presence,
- converting the encoding (this is actually not possible).
Contrary to its documentation, strings.ToValidUTF8 doesn't copy the
string if it's valid UTF-8:
<https://golang.org/src/strings/strings.go?s=15815:15861#L623>
WebSocket connections allow web-based clients to connect to IRC. This
commit implements the WebSocket sub-protocol as specified by the pending
IRCv3 proposal [1].
WebSocket listeners can now be set up via a "wss" protocol in the
`listen` directive. The new `http-origin` directive allows the CORS
allowed origins to be configured.
[1]: https://github.com/ircv3/ircv3-specifications/pull/342
Go sets a default keep-alive interval of 15 seconds on all TCP
connections, if the platform supports it. See
net.ListenConfig.KeepAlive and net.Dialer.KeepAlive.
Close the connection in conn.Close. This ensures the connection isn't
still alive after conn.Close, which would cause issues when
disconnecting and reconnecting quickly to an upstream server.
Unfortunately, I don't think there's a good way to implement net.Conn
semantics on top of channels. The Close and SendMessage methods should
gracefully fail without panicking if the connection is already closed.
Using only channels leads to race conditions.
We could remove the lock if Close and SendMessage are only called from a
single goroutine. However that's not the case right now.
Closes: https://todo.sr.ht/~emersion/soju/55