This avoids blocking on upstream message rate limiting for too
long.
git-svn-id: file:///srv/svn/repo/suika/trunk@757 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Makes it easy to print debugging messages which aren't targeted at
the user. See [1] for motivation.
[1]: https://dave.cheney.net/2015/11/05/lets-talk-about-logging
git-svn-id: file:///srv/svn/repo/suika/trunk@747 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Instead of hand-rolling our own rate-limiter based on goroutines,
use golang.org/x/time/rate.
git-svn-id: file:///srv/svn/repo/suika/trunk@741 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This function wraps a parent context, and returns a new context
cancelled when the connection is closed. This will make it so
operations started from downstreamConn.handleMessage will be
cancelled when the connection is closed.
git-svn-id: file:///srv/svn/repo/suika/trunk@703 f0ae65fe-ee39-954e-97ec-027ff2717ef4
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
git-svn-id: file:///srv/svn/repo/suika/trunk@465 f0ae65fe-ee39-954e-97ec-027ff2717ef4
... 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>
git-svn-id: file:///srv/svn/repo/suika/trunk@415 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Allow up to 10 outgoing messages in a burst, then throttle to 1 message
each 2 seconds.
Closes: https://todo.sr.ht/~emersion/soju/87
git-svn-id: file:///srv/svn/repo/suika/trunk@398 f0ae65fe-ee39-954e-97ec-027ff2717ef4
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
git-svn-id: file:///srv/svn/repo/suika/trunk@323 f0ae65fe-ee39-954e-97ec-027ff2717ef4
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.
git-svn-id: file:///srv/svn/repo/suika/trunk@314 f0ae65fe-ee39-954e-97ec-027ff2717ef4
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.
git-svn-id: file:///srv/svn/repo/suika/trunk@312 f0ae65fe-ee39-954e-97ec-027ff2717ef4
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
git-svn-id: file:///srv/svn/repo/suika/trunk@280 f0ae65fe-ee39-954e-97ec-027ff2717ef4