Skip to content

Commit

Permalink
Bump MSRV since we were using newer features anyway.
Browse files Browse the repository at this point in the history
This also eliminates the need for the once_cell crate.
  • Loading branch information
zrax committed Jul 30, 2024
1 parent 3595357 commit 01b8267
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name = "moulars"
version = "0.1.0"
license = "AGPL-3.0-or-later"
edition = "2021"
rust-version = "1.63" # Maintain compatibility with Debian 12
rust-version = "1.70"

[dependencies]
anyhow = "1.0"
Expand All @@ -36,7 +36,6 @@ num-bigint = { version = "0.4.3", features = ["rand"] }
num-derive = "0.3"
num-prime = "0.4"
num-traits = "0.2"
once_cell = "1.17"
paste = "1.0"
rand = "0.8.5"
rc4 = "0.1.0"
Expand Down
7 changes: 4 additions & 3 deletions src/auth_srv/auth_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

use std::io::{Cursor, Write};
use std::sync::OnceLock;

use anyhow::Result;
use byteorder::{LittleEndian, WriteBytesExt};
use once_cell::sync::Lazy;
use regex::Regex;

use crate::hashes::ShaDigest;
Expand All @@ -36,11 +36,12 @@ fn write_truncated_utf16(value: &str, stream: &mut dyn Write) -> Result<()> {
}

pub fn use_email_auth(account_name: &str) -> bool {
static RE_DOMAIN: Lazy<Regex> = Lazy::new(|| {
static RE_DOMAIN: OnceLock<Regex> = OnceLock::new();
let re_domain = RE_DOMAIN.get_or_init(|| {
Regex::new("[^@]+@([^.]+\\.)*([^.]+)\\.[^.]+").unwrap()
});

if let Some(caps) = RE_DOMAIN.captures(account_name) {
if let Some(caps) = re_domain.captures(account_name) {
!caps[2].eq_ignore_ascii_case("gametap")
} else {
false
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
use std::fs::File;
use std::io::{self, BufReader, BufWriter};
use std::path::{Path, PathBuf};
use std::sync::OnceLock;

use anyhow::{anyhow, Context, Result};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use num_bigint::BigUint;
use once_cell::sync::OnceCell;
use rand::Rng;
use serde_derive::Deserialize;

Expand Down Expand Up @@ -202,7 +202,7 @@ struct VaultDbConfig {
// NOTE: This file stores the keys in Big Endian format for easier debugging
// with tools like PlasmaShop
pub fn load_or_create_ntd_key(data_root: &Path) -> io::Result<[u32; 4]> {
static NTD_KEY: OnceCell<[u32; 4]> = OnceCell::new();
static NTD_KEY: OnceLock<[u32; 4]> = OnceLock::new();
if let Some(key) = NTD_KEY.get() {
return Ok(*key);
}
Expand Down
7 changes: 4 additions & 3 deletions src/file_srv/data_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ use std::fs::File;
use std::io::{self, Cursor, BufReader, BufWriter, Write};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::sync::OnceLock;

use anyhow::{anyhow, Context, Result};
use log::{warn, info};
use once_cell::sync::Lazy;
use tempfile::{NamedTempFile, TempDir};

use crate::path_utils;
Expand Down Expand Up @@ -71,7 +71,8 @@ fn scan_python_dir(python_root: &Path, subdir_limit: Option<&Vec<&OsStr>>)
}

pub fn cache_clients(data_root: &Path, python_exe: Option<&Path>) -> Result<()> {
static CLIENT_TYPES: Lazy<Vec<(&str, &str, PathBuf)>> = Lazy::new(|| vec![
static CLIENT_TYPES: OnceLock<Vec<(&str, &str, PathBuf)>> = OnceLock::new();
let client_types = CLIENT_TYPES.get_or_init(|| vec![
("Internal", "", ["client", "windows_ia32", "internal"].iter().collect()),
("External", "", ["client", "windows_ia32", "external"].iter().collect()),
("Internal", "_x64", ["client", "windows_x64", "internal"].iter().collect()),
Expand Down Expand Up @@ -211,7 +212,7 @@ pub fn cache_clients(data_root: &Path, python_exe: Option<&Path>) -> Result<()>
secure_preloader_mfs.write_cache(&secure_preloader_mfs_path)?;
}

for (build, suffix, client_data_dir) in CLIENT_TYPES.iter() {
for (build, suffix, client_data_dir) in client_types.iter() {
let src_dir = data_root.join(client_data_dir);
if !src_dir.exists() || !src_dir.is_dir() {
warn!("{} does not exist. Skipping manifest for {}{}",
Expand Down

0 comments on commit 01b8267

Please sign in to comment.