mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-15 13:33:00 -06:00
[chore/bugfix] Break Websockets logic into smaller read/write functions, don't log expected errors (#1932)
* [chore/bugfix] Break Websockets logic into smaller read/write functions, don't log expected errors * tweak * tidy up, use control message
This commit is contained in:
parent
ba0bc06b8c
commit
3d16962173
2 changed files with 237 additions and 133 deletions
|
|
@ -42,15 +42,18 @@ type Module struct {
|
|||
}
|
||||
|
||||
func New(processor *processing.Processor, dTicker time.Duration, wsBuf int) *Module {
|
||||
// We expect CORS requests for websockets,
|
||||
// (via eg., semaphore.social) so be lenient.
|
||||
// TODO: make this customizable?
|
||||
checkOrigin := func(r *http.Request) bool { return true }
|
||||
|
||||
return &Module{
|
||||
processor: processor,
|
||||
dTicker: dTicker,
|
||||
wsUpgrade: websocket.Upgrader{
|
||||
ReadBufferSize: wsBuf, // we don't expect reads
|
||||
ReadBufferSize: wsBuf,
|
||||
WriteBufferSize: wsBuf,
|
||||
|
||||
// we expect cors requests (via eg., semaphore.social) so be lenient
|
||||
CheckOrigin: func(r *http.Request) bool { return true },
|
||||
CheckOrigin: checkOrigin,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue