Update cert and random handling.

This commit is contained in:
yukirij 2024-09-03 23:17:51 -07:00
parent 23f4847956
commit e4f68dc652
2 changed files with 13 additions and 6 deletions

View File

@ -249,8 +249,13 @@ async fn main()
}
let mut tls_server = TlsServer::new();
if tls_server.add_cert("omen.kirisame.com", "cert/fullchain.pem", "cert/privkey.pem").await.is_err() {
println!("error: failed to load TLS certificates.");
for domain in [
"omen.kirisame.com",
"dzura.com",
] {
if tls_server.add_cert(domain, &format!("cert/{}/fullchain.pem", domain), &format!("cert/{}/privkey.pem", domain)).await.is_err() {
println!("error: failed to load TLS certificates for {}.", domain);
}
}
match tls_server.bind("0.0.0.0:38612").await {
Ok(_) => {

View File

@ -581,8 +581,10 @@ pub async fn thread_system(mut app:App, bus:Bus<protocol::QRPacket>)
let chain_id = app.session_time.add(token);
// Choose player seats.
let mut seats = [0u8; 1];
rng.fill(&mut seats).ok();
let mut seats = [0u8; 8];
if rng.fill(&mut seats).is_err() {
println!("RNG error");
}
// Build session.
let mut session = Session {
@ -591,11 +593,11 @@ pub async fn thread_system(mut app:App, bus:Bus<protocol::QRPacket>)
secret,
game:game::Game::new(),
p_dawn:Player {
user:if (seats[0] & 1) == 0 { Some(user_id) } else { Some(chal_id) },
user:if (seats[0] & 8) == 0 { Some(user_id) } else { Some(chal_id) },
connections:Vec::new(),
},
p_dusk:Player {
user:if (seats[0] & 1) == 0 { Some(chal_id) } else { Some(user_id) },
user:if (seats[0] & 8) == 0 { Some(chal_id) } else { Some(user_id) },
connections:Vec::new(),
},
connections:Vec::new(),