mirror of
https://github.com/telemt/telemt.git
synced 2026-06-27 13:21:10 +03:00
Rustfmt
This commit is contained in:
+1
-6
@@ -1002,12 +1002,7 @@ impl RunningClientHandler {
|
||||
trusted = ?self.config.server.proxy_protocol_trusted_cidrs,
|
||||
"Rejecting PROXY protocol header from untrusted source"
|
||||
);
|
||||
record_beobachten_class(
|
||||
&self.beobachten,
|
||||
&self.config,
|
||||
self.peer.ip(),
|
||||
"other",
|
||||
);
|
||||
record_beobachten_class(&self.beobachten, &self.config, self.peer.ip(), "other");
|
||||
return Err(ProxyError::InvalidProxyProtocol);
|
||||
}
|
||||
|
||||
|
||||
@@ -1901,7 +1901,10 @@ where
|
||||
.auth_expensive_checks_total
|
||||
.fetch_add(validation_checks as u64, Ordering::Relaxed);
|
||||
|
||||
if config.access.is_user_source_ip_denied(user.as_str(), peer.ip()) {
|
||||
if config
|
||||
.access
|
||||
.is_user_source_ip_denied(user.as_str(), peer.ip())
|
||||
{
|
||||
auth_probe_record_failure_in(shared, peer.ip(), Instant::now());
|
||||
maybe_apply_server_hello_delay(config).await;
|
||||
warn!(
|
||||
|
||||
+20
-23
@@ -1883,9 +1883,7 @@ where
|
||||
};
|
||||
|
||||
// When client closes, but ME channel stopped as unregistered - it isnt error
|
||||
if client_closed
|
||||
&& matches!(writer_result, Err(ProxyError::MiddleConnectionLost))
|
||||
{
|
||||
if client_closed && matches!(writer_result, Err(ProxyError::MiddleConnectionLost)) {
|
||||
writer_result = Ok(());
|
||||
}
|
||||
|
||||
@@ -2520,27 +2518,26 @@ where
|
||||
)
|
||||
.await?;
|
||||
|
||||
let write_mode =
|
||||
match write_client_payload(
|
||||
client_writer,
|
||||
proto_tag,
|
||||
flags,
|
||||
&data,
|
||||
rng,
|
||||
frame_buf,
|
||||
cancel,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(mode) => mode,
|
||||
Err(err) => {
|
||||
if quota_limit.is_some() {
|
||||
stats.add_quota_write_fail_bytes_total(data_len);
|
||||
stats.increment_quota_write_fail_events_total();
|
||||
}
|
||||
return Err(err);
|
||||
let write_mode = match write_client_payload(
|
||||
client_writer,
|
||||
proto_tag,
|
||||
flags,
|
||||
&data,
|
||||
rng,
|
||||
frame_buf,
|
||||
cancel,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(mode) => mode,
|
||||
Err(err) => {
|
||||
if quota_limit.is_some() {
|
||||
stats.add_quota_write_fail_bytes_total(data_len);
|
||||
stats.increment_quota_write_fail_events_total();
|
||||
}
|
||||
};
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
|
||||
bytes_me2c.fetch_add(data_len, Ordering::Relaxed);
|
||||
if let Some(user_stats) = quota_user_stats {
|
||||
|
||||
+2
-9
@@ -518,10 +518,7 @@ impl<S: AsyncRead + Unpin> AsyncRead for StatsIo<S> {
|
||||
Poll::Ready(Ok(n)) => {
|
||||
if reserved_read_bytes > n as u64 {
|
||||
let refund_bytes = reserved_read_bytes - n as u64;
|
||||
refund_reserved_quota_bytes(
|
||||
this.user_stats.as_ref(),
|
||||
refund_bytes,
|
||||
);
|
||||
refund_reserved_quota_bytes(this.user_stats.as_ref(), refund_bytes);
|
||||
this.stats.add_quota_refund_bytes_total(refund_bytes);
|
||||
}
|
||||
if n > 0 {
|
||||
@@ -538,7 +535,6 @@ impl<S: AsyncRead + Unpin> AsyncRead for StatsIo<S> {
|
||||
this.quota_bytes_since_check = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if let Some(limit) = this.quota_limit
|
||||
&& this.user_stats.quota_used() >= limit
|
||||
@@ -700,10 +696,7 @@ impl<S: AsyncWrite + Unpin> AsyncWrite for StatsIo<S> {
|
||||
Poll::Ready(Ok(n)) => {
|
||||
if reserved_bytes > n as u64 {
|
||||
let refund_bytes = reserved_bytes - n as u64;
|
||||
refund_reserved_quota_bytes(
|
||||
this.user_stats.as_ref(),
|
||||
refund_bytes,
|
||||
);
|
||||
refund_reserved_quota_bytes(this.user_stats.as_ref(), refund_bytes);
|
||||
this.stats.add_quota_refund_bytes_total(refund_bytes);
|
||||
}
|
||||
if shaper_reserved_bytes > n as u64
|
||||
|
||||
@@ -1519,10 +1519,7 @@ async fn direct_relay_cutover_midflight_releases_route_gauge() {
|
||||
"cutover should terminate direct relay session"
|
||||
);
|
||||
assert!(
|
||||
matches!(
|
||||
relay_result,
|
||||
Err(ProxyError::RouteSwitched)
|
||||
),
|
||||
matches!(relay_result, Err(ProxyError::RouteSwitched)),
|
||||
"client-visible cutover error must stay generic and avoid route-internal metadata"
|
||||
);
|
||||
|
||||
@@ -1659,10 +1656,7 @@ async fn direct_relay_cutover_storm_multi_session_keeps_generic_errors_and_relea
|
||||
.expect("direct relay task must not panic");
|
||||
|
||||
assert!(
|
||||
matches!(
|
||||
relay_result,
|
||||
Err(ProxyError::RouteSwitched)
|
||||
),
|
||||
matches!(relay_result, Err(ProxyError::RouteSwitched)),
|
||||
"storm-cutover termination must remain generic for all direct sessions"
|
||||
);
|
||||
}
|
||||
@@ -1965,10 +1959,7 @@ async fn adversarial_direct_relay_cutover_integrity() {
|
||||
.expect("Session must not panic");
|
||||
|
||||
assert!(
|
||||
matches!(
|
||||
result,
|
||||
Err(ProxyError::RouteSwitched)
|
||||
),
|
||||
matches!(result, Err(ProxyError::RouteSwitched)),
|
||||
"Session must terminate with route switch error on cutover"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -187,12 +187,8 @@ fn poll_read_once<R: AsyncRead + Unpin>(
|
||||
#[test]
|
||||
fn direct_c2s_quota_refunds_unused_on_short_read() {
|
||||
let user = "direct-c2s-short-read-refund-user";
|
||||
let (mut io, stats, read_calls, quota_exceeded) = make_stats_io_with_read_script(
|
||||
user,
|
||||
64,
|
||||
0,
|
||||
vec![ReadStep::Data(vec![0x11; 5])],
|
||||
);
|
||||
let (mut io, stats, read_calls, quota_exceeded) =
|
||||
make_stats_io_with_read_script(user, 64, 0, vec![ReadStep::Data(vec![0x11; 5])]);
|
||||
let mut storage = [0u8; 16];
|
||||
|
||||
let n = match poll_read_once(&mut io, &mut storage) {
|
||||
|
||||
Reference in New Issue
Block a user