mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Modify message catch-all arms
This commit is contained in:
parent
466c1c4dcb
commit
042d258161
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Improved site placement
|
- Improved site placement
|
||||||
|
- [Server] Kick clients who send messages on the wrong stream
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -175,7 +175,13 @@ impl Sys {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => tracing::error!("not a client_character_screen msg"),
|
_ => {
|
||||||
|
debug!("Kicking possibly misbehaving client due to invalid character request");
|
||||||
|
server_emitter.emit(ServerEvent::ClientDisconnect(
|
||||||
|
entity,
|
||||||
|
common::comp::DisconnectReason::NetworkError,
|
||||||
|
));
|
||||||
|
},
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,13 @@ impl Sys {
|
|||||||
common::comp::DisconnectReason::ClientRequested,
|
common::comp::DisconnectReason::ClientRequested,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
_ => tracing::error!("not a client_general msg"),
|
_ => {
|
||||||
|
debug!("Kicking possible misbehaving client due to invalid message request");
|
||||||
|
server_emitter.emit(ServerEvent::ClientDisconnect(
|
||||||
|
entity,
|
||||||
|
common::comp::DisconnectReason::NetworkError,
|
||||||
|
));
|
||||||
|
},
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,13 @@ impl Sys {
|
|||||||
| ClientGeneral::TerrainChunkRequest { .. }
|
| ClientGeneral::TerrainChunkRequest { .. }
|
||||||
| ClientGeneral::ChatMsg(_)
|
| ClientGeneral::ChatMsg(_)
|
||||||
| ClientGeneral::Command(..)
|
| ClientGeneral::Command(..)
|
||||||
| ClientGeneral::Terminate => tracing::error!("not a client_in_game msg"),
|
| ClientGeneral::Terminate => {
|
||||||
|
debug!("Kicking possibly misbehaving client due to invalid client in game request");
|
||||||
|
server_emitter.emit(ServerEvent::ClientDisconnect(
|
||||||
|
entity,
|
||||||
|
common::comp::DisconnectReason::NetworkError,
|
||||||
|
));
|
||||||
|
},
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::{client::Client, metrics::NetworkRequestMetrics, presence::Presence, ChunkRequest};
|
use crate::{client::Client, metrics::NetworkRequestMetrics, presence::Presence, ChunkRequest};
|
||||||
use common::{
|
use common::{
|
||||||
comp::Pos,
|
comp::Pos,
|
||||||
|
event::{EventBus, ServerEvent},
|
||||||
spiral::Spiral2d,
|
spiral::Spiral2d,
|
||||||
terrain::{TerrainChunkSize, TerrainGrid},
|
terrain::{TerrainChunkSize, TerrainGrid},
|
||||||
vol::RectVolSize,
|
vol::RectVolSize,
|
||||||
@ -8,7 +9,7 @@ use common::{
|
|||||||
use common_ecs::{Job, Origin, ParMode, Phase, System};
|
use common_ecs::{Job, Origin, ParMode, Phase, System};
|
||||||
use common_net::msg::{ClientGeneral, SerializedTerrainChunk, ServerGeneral};
|
use common_net::msg::{ClientGeneral, SerializedTerrainChunk, ServerGeneral};
|
||||||
use rayon::iter::ParallelIterator;
|
use rayon::iter::ParallelIterator;
|
||||||
use specs::{Entities, Join, ParJoin, ReadExpect, ReadStorage, Write};
|
use specs::{Entities, Join, ParJoin, Read, ReadExpect, ReadStorage, Write};
|
||||||
use tracing::{debug, trace};
|
use tracing::{debug, trace};
|
||||||
|
|
||||||
/// This system will handle new messages from clients
|
/// This system will handle new messages from clients
|
||||||
@ -17,6 +18,7 @@ pub struct Sys;
|
|||||||
impl<'a> System<'a> for Sys {
|
impl<'a> System<'a> for Sys {
|
||||||
type SystemData = (
|
type SystemData = (
|
||||||
Entities<'a>,
|
Entities<'a>,
|
||||||
|
Read<'a, EventBus<ServerEvent>>,
|
||||||
ReadExpect<'a, TerrainGrid>,
|
ReadExpect<'a, TerrainGrid>,
|
||||||
ReadExpect<'a, NetworkRequestMetrics>,
|
ReadExpect<'a, NetworkRequestMetrics>,
|
||||||
Write<'a, Vec<ChunkRequest>>,
|
Write<'a, Vec<ChunkRequest>>,
|
||||||
@ -33,6 +35,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
job: &mut Job<Self>,
|
job: &mut Job<Self>,
|
||||||
(
|
(
|
||||||
entities,
|
entities,
|
||||||
|
server_event_bus,
|
||||||
terrain,
|
terrain,
|
||||||
network_metrics,
|
network_metrics,
|
||||||
mut chunk_requests,
|
mut chunk_requests,
|
||||||
@ -47,6 +50,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
.map(|(entity, client, maybe_presence)| {
|
.map(|(entity, client, maybe_presence)| {
|
||||||
let mut chunk_requests = Vec::new();
|
let mut chunk_requests = Vec::new();
|
||||||
let _ = super::try_recv_all(client, 5, |client, msg| {
|
let _ = super::try_recv_all(client, 5, |client, msg| {
|
||||||
|
// TODO: Refactor things (https://gitlab.com/veloren/veloren/-/merge_requests/3245#note_856538056)
|
||||||
|
let mut server_emitter = server_event_bus.emitter();
|
||||||
let presence = match maybe_presence {
|
let presence = match maybe_presence {
|
||||||
Some(g) => g,
|
Some(g) => g,
|
||||||
None => {
|
None => {
|
||||||
@ -96,7 +101,16 @@ impl<'a> System<'a> for Sys {
|
|||||||
network_metrics.chunks_request_dropped.inc();
|
network_metrics.chunks_request_dropped.inc();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => tracing::error!("not a client_terrain msg"),
|
_ => {
|
||||||
|
debug!(
|
||||||
|
"Kicking possibly misbehaving client due to invalud terrain \
|
||||||
|
request"
|
||||||
|
);
|
||||||
|
server_emitter.emit(ServerEvent::ClientDisconnect(
|
||||||
|
entity,
|
||||||
|
common::comp::DisconnectReason::NetworkError,
|
||||||
|
));
|
||||||
|
},
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user