diff --git a/crates/voelin-core/src/ts_session/live_tests.rs b/crates/voelin-core/src/ts_session/live_tests.rs index 45abc4c..e08b90b 100644 --- a/crates/voelin-core/src/ts_session/live_tests.rs +++ b/crates/voelin-core/src/ts_session/live_tests.rs @@ -20,6 +20,15 @@ //! //! The sessions are made by [`TsConnector`] through the plain `Connector` //! interface, as a client of the seam outside an engine would make them. +//! +//! The servers ban an address that connects as often as these tests do +//! (`ConnectFailedBanned` after three or four connections) unless their +//! anti-flood limits are raised first. `scripts/it-smoke.sh` raises them when it +//! prepares its admin identity; this module raises them itself, once per server +//! and run, through the ServerQuery admin login that `refused_moves` uses +//! ([`raise_flood_limits`]), so that the command above works on a freshly +//! started stack. It needs that login (the development servers of +//! `dev/docker-compose.yml` have it) and does not lower the limits again. use std::collections::BTreeMap; use std::future::Future; @@ -89,12 +98,47 @@ impl Dev { } } +/// Raise the anti-flood limits of a development server, once per run, and +/// lift the bans an earlier run left behind. The tests connect many times in +/// a few seconds from one address, which a server with its default limits +/// bans (`ConnectFailedBanned`); `scripts/it-smoke.sh` sets the same two +/// values in `admin_args`. Done through the ServerQuery login of the admin, +/// which the tests that create channels and keys use as well. +async fn raise_flood_limits(dev: &Dev) { + use tokio::sync::OnceCell; + use voelin_query::{Command as Query, QueryClient}; + static TS3_READY: OnceCell<()> = OnceCell::const_new(); + static TS6_READY: OnceCell<()> = OnceCell::const_new(); + let ready = if dev.ssh { &TS6_READY } else { &TS3_READY }; + ready + .get_or_init(|| async { + let (admin, _) = within("the query login", QueryClient::connect(&dev.query())) + .await + .unwrap_or_else(|e| panic!("the query login of {}: {e}", dev.name)); + for key in [ + "virtualserver_antiflood_points_needed_ip_block", + "virtualserver_antiflood_points_needed_command_block", + ] { + let edit = Query::new("serveredit").arg(key, 100_000); + within("the anti-flood limits", admin.send(&edit)) + .await + .unwrap_or_else(|e| panic!("{} refused {key}: {e}", dev.name)); + } + // A ban of an earlier run outlives the change of the limit. + within("the ban list", admin.send(&Query::new("bandelall"))) + .await + .unwrap_or_else(|e| panic!("{} did not lift its bans: {e}", dev.name)); + }) + .await; +} + /// A TeamSpeak session as a client of the seam sees it: made by the /// connector, with its push channel and media sink. async fn session( dev: &Dev, options: &ConnectOptions, ) -> (Arc, mpsc::Receiver, MediaReceiver) { + raise_flood_limits(dev).await; let (sink, media) = media_channel(); let params = connect_params(options, sink, &Backends::empty()).expect("connect parameters"); let connected =