Add ws-max-paxload (#155)
This commit is contained in:
parent
f9f536cd08
commit
8f794afdb5
@ -466,6 +466,10 @@ usage! {
|
||||
"--ws-max-connections=[CONN]",
|
||||
"Maximum number of allowed concurrent WebSockets JSON-RPC connections.",
|
||||
|
||||
ARG arg_ws_max_payload: (usize) = 5usize, or |c: &Config| c.websockets.as_ref()?.max_payload,
|
||||
"--ws-max-payload=[MB]",
|
||||
"Specify maximum size for WS JSON-RPC requests in megabytes.",
|
||||
|
||||
["Metrics"]
|
||||
FLAG flag_metrics: (bool) = false, or |c: &Config| c.metrics.as_ref()?.enable.clone(),
|
||||
"--metrics",
|
||||
@ -903,6 +907,7 @@ struct Ws {
|
||||
origins: Option<Vec<String>>,
|
||||
hosts: Option<Vec<String>>,
|
||||
max_connections: Option<usize>,
|
||||
max_payload: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
@ -1323,6 +1328,7 @@ mod tests {
|
||||
arg_ws_origins: "none".into(),
|
||||
arg_ws_hosts: "none".into(),
|
||||
arg_ws_max_connections: 100,
|
||||
arg_ws_max_payload: 5,
|
||||
|
||||
// IPC
|
||||
flag_no_ipc: false,
|
||||
@ -1512,6 +1518,7 @@ mod tests {
|
||||
origins: Some(vec!["none".into()]),
|
||||
hosts: None,
|
||||
max_connections: None,
|
||||
max_payload: None,
|
||||
}),
|
||||
rpc: Some(Rpc {
|
||||
disable: Some(true),
|
||||
|
@ -951,6 +951,7 @@ impl Configuration {
|
||||
signer_path: self.directories().signer.into(),
|
||||
support_token_api,
|
||||
max_connections: self.args.arg_ws_max_connections,
|
||||
max_payload: self.args.arg_ws_max_payload,
|
||||
};
|
||||
|
||||
Ok(conf)
|
||||
@ -1483,6 +1484,7 @@ mod tests {
|
||||
signer_path: expected.into(),
|
||||
support_token_api: true,
|
||||
max_connections: 100,
|
||||
max_payload: 5,
|
||||
},
|
||||
LogConfig {
|
||||
color: !cfg!(windows),
|
||||
|
@ -97,6 +97,7 @@ pub struct WsConfiguration {
|
||||
pub hosts: Option<Vec<String>>,
|
||||
pub signer_path: PathBuf,
|
||||
pub support_token_api: bool,
|
||||
pub max_payload: usize,
|
||||
}
|
||||
|
||||
impl Default for WsConfiguration {
|
||||
@ -116,6 +117,7 @@ impl Default for WsConfiguration {
|
||||
hosts: Some(Vec::new()),
|
||||
signer_path: replace_home(&data_dir, "$BASE/signer").into(),
|
||||
support_token_api: true,
|
||||
max_payload: 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,6 +196,7 @@ pub fn new_ws<D: rpc_apis::Dependencies>(
|
||||
rpc::WsExtractor::new(path.clone()),
|
||||
rpc::WsExtractor::new(path.clone()),
|
||||
rpc::WsStats::new(deps.stats.clone()),
|
||||
conf.max_payload,
|
||||
);
|
||||
|
||||
// match start_result {
|
||||
|
@ -223,6 +223,7 @@ pub fn start_ws<M, S, H, T, U, V>(
|
||||
extractor: T,
|
||||
middleware: V,
|
||||
stats: U,
|
||||
max_payload: usize,
|
||||
) -> Result<ws::Server, ws::Error>
|
||||
where
|
||||
M: jsonrpc_core::Metadata,
|
||||
@ -237,6 +238,7 @@ where
|
||||
.allowed_origins(allowed_origins)
|
||||
.allowed_hosts(allowed_hosts)
|
||||
.max_connections(max_connections)
|
||||
.max_payload(max_payload * 1024 * 1024)
|
||||
.session_stats(stats)
|
||||
.start(addr)
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ pub fn serve() -> (Server<ws::Server>, usize, GuardedAuthCodes) {
|
||||
extractors::WsExtractor::new(Some(&authcodes.path)),
|
||||
extractors::WsExtractor::new(Some(&authcodes.path)),
|
||||
extractors::WsStats::new(stats),
|
||||
5 * 1024 * 1024,
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user