Sfoglia il codice sorgente

perf: new ws listener option to disable UTF-8 validation

William Yang 2 anni fa
parent
commit
726302ef6a

+ 8 - 0
apps/emqx/src/emqx_schema.erl

@@ -1104,6 +1104,14 @@ fields("ws_opts") ->
             sc(
                 ref("deflate_opts"),
                 #{}
+            )},
+        {"validate_utf8",
+            sc(
+                boolean(),
+                #{
+                    default => true,
+                    desc => ?DESC(fields_ws_opts_validate_utf8)
+                }
             )}
     ];
 fields("tcp_opts") ->

+ 2 - 1
apps/emqx/src/emqx_ws_connection.erl

@@ -205,7 +205,8 @@ init(Req, #{listener := {Type, Listener}} = Opts) ->
         compress => get_ws_opts(Type, Listener, compress),
         deflate_opts => get_ws_opts(Type, Listener, deflate_opts),
         max_frame_size => get_ws_opts(Type, Listener, max_frame_size),
-        idle_timeout => get_ws_opts(Type, Listener, idle_timeout)
+        idle_timeout => get_ws_opts(Type, Listener, idle_timeout),
+        validate_utf8 => get_ws_opts(Type, Listener, validate_utf8)
     },
     case check_origin_header(Req, Opts) of
         {error, Reason} ->

+ 7 - 0
rel/i18n/emqx_schema.hocon

@@ -1275,6 +1275,13 @@ fields_ws_opts_allow_origin_absence.desc:
 fields_ws_opts_allow_origin_absence.label:
 """Allow origin absence"""
 
+fields_ws_opts_validate_utf8.desc:
+"""Set to <code>false</code> to disable WebSocket Frame UTF-8
+  validation for performance"""
+
+fields_ws_opts_validate_utf8.label:
+"""Enable/Disable WebSocket Frame utf8 validation"""
+
 common_ssl_opts_schema_versions.desc:
 """All TLS/DTLS versions to be supported.<br/>
 NOTE: PSK ciphers are suppressed by 'tlsv1.3' version config.<br/>