websocket: accepts config value with units

Ticket: 8552

As was the commented out example
pull/15636/head
Philippe Antoine 5 months ago committed by Victor Julien
parent 565e138754
commit c6014a77a2

@ -17,7 +17,7 @@
use super::parser; use super::parser;
use crate::applayer::{self, *}; use crate::applayer::{self, *};
use crate::conf::conf_get; use crate::conf::{conf_get, get_memval};
use crate::core::{ use crate::core::{
sc_app_layer_parser_trigger_raw_stream_inspection, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP, sc_app_layer_parser_trigger_raw_stream_inspection, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP,
}; };
@ -437,8 +437,15 @@ pub unsafe extern "C" fn SCRegisterWebSocketParser() {
} }
SCLogDebug!("Rust websocket parser registered."); SCLogDebug!("Rust websocket parser registered.");
if let Some(val) = conf_get("app-layer.protocols.websocket.max-payload-size") { if let Some(val) = conf_get("app-layer.protocols.websocket.max-payload-size") {
if let Ok(v) = val.parse::<u32>() { if let Ok(v) = get_memval(val) {
WEBSOCKET_MAX_PAYLOAD_SIZE = v; if let Ok(vu) = u32::try_from(v) {
WEBSOCKET_MAX_PAYLOAD_SIZE = vu;
} else {
SCLogError!(
"Too big value for websocket.max-payload-size: max is {}.",
u32::MAX
);
}
} else { } else {
SCLogError!("Invalid value for websocket.max-payload-size"); SCLogError!("Invalid value for websocket.max-payload-size");
} }

Loading…
Cancel
Save