diff --git a/go.mod b/go.mod index 1ee52064d9..6dad8390f4 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/FZambia/eagle v0.1.0 github.com/FZambia/statik v0.1.2-0.20180217151304-b9f012bb2a1b github.com/centrifugal/centrifuge v0.33.5-0.20241026095149-106d43f21426 - github.com/centrifugal/protocol v0.13.4 + github.com/centrifugal/protocol v0.13.5-0.20241030063749-f2e17f373602 github.com/cristalhq/jwt/v5 v5.4.0 github.com/go-viper/mapstructure/v2 v2.1.0 github.com/gobwas/glob v0.2.3 diff --git a/go.sum b/go.sum index bf043a1c0b..557a05f47c 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3 github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/centrifugal/centrifuge v0.33.5-0.20241026095149-106d43f21426 h1:g5zZaCr/BybYgq8Nqrnrvqvb3jGGO/Dloil3cFGzzbg= github.com/centrifugal/centrifuge v0.33.5-0.20241026095149-106d43f21426/go.mod h1:Ck+7H3eVwoeyabKcj3L55oSunaORIOGPAIVB5xrQyGU= -github.com/centrifugal/protocol v0.13.4 h1:I0YxXtFNfn/ndDIZp5RkkqQcSSNH7DNPUbXKYtJXDzs= -github.com/centrifugal/protocol v0.13.4/go.mod h1:7V5vI30VcoxJe4UD87xi7bOsvI0bmEhvbQuMjrFM2L4= +github.com/centrifugal/protocol v0.13.5-0.20241030063749-f2e17f373602 h1:GdltAOXAFqR9i/q/DWbGzWFXv6x5ff/oPgZFuwlIZFQ= +github.com/centrifugal/protocol v0.13.5-0.20241030063749-f2e17f373602/go.mod h1:7V5vI30VcoxJe4UD87xi7bOsvI0bmEhvbQuMjrFM2L4= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= diff --git a/internal/api/const.go b/internal/api/const.go deleted file mode 100644 index 778f64ec17..0000000000 --- a/internal/api/const.go +++ /dev/null @@ -1 +0,0 @@ -package api diff --git a/internal/configtypes/types.go b/internal/configtypes/types.go index bb64ac3d71..635e5862b0 100644 --- a/internal/configtypes/types.go +++ b/internal/configtypes/types.go @@ -56,8 +56,9 @@ type HTTPStream struct { } type WebTransport struct { - Enabled bool `mapstructure:"enabled" json:"enabled" envconfig:"enabled" yaml:"enabled" toml:"enabled"` - HandlerPrefix string `mapstructure:"handler_prefix" json:"handler_prefix" envconfig:"handler_prefix" default:"/connection/webtransport" yaml:"handler_prefix" toml:"handler_prefix"` + Enabled bool `mapstructure:"enabled" json:"enabled" envconfig:"enabled" yaml:"enabled" toml:"enabled"` + HandlerPrefix string `mapstructure:"handler_prefix" json:"handler_prefix" envconfig:"handler_prefix" default:"/connection/webtransport" yaml:"handler_prefix" toml:"handler_prefix"` + MessageSizeLimit int `mapstructure:"message_size_limit" json:"message_size_limit" envconfig:"message_size_limit" default:"65536" yaml:"message_size_limit" toml:"message_size_limit"` } type UniWebSocket struct { diff --git a/internal/wt/handler.go b/internal/wt/handler.go index 580a16367e..cee6780851 100644 --- a/internal/wt/handler.go +++ b/internal/wt/handler.go @@ -67,14 +67,17 @@ func (s *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { var decoder protocol.StreamCommandDecoder if protoType == centrifuge.ProtocolTypeJSON { - decoder = protocol.NewJSONStreamCommandDecoder(stream) + decoder = protocol.GetStreamCommandDecoder(protocol.TypeJSON, stream, s.config.MessageSizeLimit) + defer protocol.PutStreamCommandDecoder(protocol.TypeJSON, decoder) } else { - decoder = protocol.NewProtobufStreamCommandDecoder(stream) + decoder = protocol.NewProtobufStreamCommandDecoder(stream, s.config.MessageSizeLimit) + defer protocol.PutStreamCommandDecoder(protocol.TypeProtobuf, decoder) } for { cmd, cmdSize, err := decoder.Decode() if err != nil { + s.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelError, "error decoding command", map[string]any{"client": c.ID(), "transport": transportName, "error": err.Error()})) return } ok := c.HandleCommand(cmd, cmdSize)