make websocket per-message compression optional

This commit is contained in:
or-else
2023-03-29 09:27:39 -07:00
parent 1466226594
commit e27e4ef4a7
3 changed files with 14 additions and 1 deletions

View File

@ -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 },
}

View File

@ -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

View File

@ -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": "/",