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