mirror of
https://github.com/tinode/chat.git
synced 2025-03-14 10:05:07 +00:00
make websocket per-message compression optional
This commit is contained in:
@ -159,7 +159,7 @@ func wsWrite(ws *websocket.Conn, mt int, msg any) error {
|
||||
var upgrader = websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
EnableCompression: true,
|
||||
EnableCompression: globals.wsCompression,
|
||||
// Allow connections from any Origin
|
||||
CheckOrigin: func(r *http.Request) bool { return true },
|
||||
}
|
||||
|
@ -195,6 +195,9 @@ var globals struct {
|
||||
|
||||
// ICE servers config (video calling)
|
||||
iceServers []iceServer
|
||||
|
||||
// Websocket per-message compression negotiation is enabled.
|
||||
wsCompression bool
|
||||
}
|
||||
|
||||
// Credential validator config.
|
||||
@ -245,6 +248,9 @@ type configType struct {
|
||||
ApiPath string `json:"api_path"`
|
||||
// Cache-Control value for static content.
|
||||
CacheControl int `json:"cache_control"`
|
||||
// If true, do not attempt to negotiate websocket per message compression (RFC 7692.4).
|
||||
// It should be disabled (set to true) if you are using MSFT IIS as reverse proxy.
|
||||
WSCompressionDisabled bool `json:"ws_compression_disabled"`
|
||||
// Address:port to listen for gRPC clients. If blank gRPC support will not be initialized.
|
||||
// Could be overridden from the command line with --grpc_listen.
|
||||
GrpcListen string `json:"grpc_listen"`
|
||||
@ -545,6 +551,9 @@ func main() {
|
||||
globals.defaultCountryCode = defaultCountryCode
|
||||
}
|
||||
|
||||
// Websocket compression.
|
||||
globals.wsCompression = !config.WSCompressionDisabled
|
||||
|
||||
if config.Media != nil {
|
||||
if config.Media.UseHandler == "" {
|
||||
config.Media = nil
|
||||
|
@ -15,6 +15,10 @@
|
||||
// Cache-Control header for static content in seconds. 39600 is 11 hours.
|
||||
"cache_control": 39600,
|
||||
|
||||
// If true, do not attempt to negotiate websocket per message compression (RFC 7692.4).
|
||||
// It should be disabled (set to true) if you are using MSFT IIS as a reverse proxy.
|
||||
"ws_compression_disabled": false,
|
||||
|
||||
// URL path for mounting the directory with static files.
|
||||
"static_mount": "/",
|
||||
|
||||
|
Reference in New Issue
Block a user