WIP: hash inequality seems to be happening from something on the wire

This commit is contained in:
Dave Hrycyszyn
2024-06-18 10:17:59 +01:00
parent e9870241cb
commit 416d1ad88b
8 changed files with 92 additions and 21 deletions

View File

@@ -8,6 +8,10 @@ edition = "2021"
[dependencies]
async-trait = "0.1.52"
ezsockets = { version = "*", features = ["tungstenite"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.117"
sha256 = "1.5.0"
side-node = { path = "../side-node" }
tokio = { version = "1.17.0", features = ["full"] }
tracing = "0.1.32"
tracing-subscriber = "0.3.9"

View File

@@ -85,12 +85,13 @@ impl ezsockets::ServerExt for ChatServer {
.unzip();
tracing::info!(
"sending {text} to [{sessions}] at `{room}`",
"sending {hash} to [{sessions}] at `{room}`",
sessions = ids
.iter()
.map(|id| id.to_string())
.collect::<Vec<_>>()
.join(",")
.join(","),
hash = shappy(text.clone())
);
for session in sessions {
session.text(text.clone()).unwrap();
@@ -144,7 +145,7 @@ impl ezsockets::SessionExt for SessionActor {
}
async fn on_text(&mut self, text: String) -> Result<(), Error> {
tracing::info!("received: {text}");
tracing::info!("received: {}", shappy(text.clone()));
if text.starts_with('/') {
let mut args = text.split_whitespace();
let command = args.next().unwrap();
@@ -183,6 +184,11 @@ impl ezsockets::SessionExt for SessionActor {
}
}
fn shappy(text: String) -> String {
let b = text.into_bytes();
sha256::digest(b).to_string()
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();