remove dead code

This commit is contained in:
Face
2025-08-22 18:42:50 +03:00
parent 762161ff93
commit bde7d9ab5e
3 changed files with 6 additions and 13 deletions

View File

@@ -31,7 +31,6 @@ pub fn generate_ca_cert() -> Result<(String, String)> {
let serial = openssl::bn::BigNum::from_u32(1)?.to_asn1_integer()?;
cert_builder.set_serial_number(&serial)?;
let context = cert_builder.x509v3_context(None, None);
let basic_constraints = openssl::x509::extension::BasicConstraints::new()
.critical()
.ca()

View File

@@ -7,22 +7,20 @@ mod ca;
use crate::{auth::jwt_middleware_gurt, config::Config, discord_bot};
use colored::Colorize;
use macros_rs::fmt::{crashln, string};
use std::{net::IpAddr, str::FromStr, sync::Arc, collections::HashMap};
use std::{sync::Arc, collections::HashMap};
use gurt::prelude::*;
use gurt::{GurtStatusCode, Route};
#[derive(Clone)]
pub(crate) struct AppState {
trusted: IpAddr,
config: Config,
db: sqlx::PgPool,
jwt_secret: String,
}
impl AppState {
pub fn new(trusted: IpAddr, config: Config, db: sqlx::PgPool, jwt_secret: String) -> Self {
pub fn new(config: Config, db: sqlx::PgPool, jwt_secret: String) -> Self {
Self {
trusted,
config,
db,
jwt_secret,
@@ -198,11 +196,6 @@ impl GurtHandler for AppHandler {
pub async fn start(cli: crate::Cli) -> std::io::Result<()> {
let config = Config::new().set_path(&cli.config).read();
let trusted_ip = match IpAddr::from_str(&config.server.address) {
Ok(addr) => addr,
Err(err) => crashln!("Cannot parse address.\n{}", string!(err).white()),
};
let db = match config.connect_to_db().await {
Ok(pool) => pool,
Err(err) => crashln!("Failed to connect to PostgreSQL database.\n{}", string!(err).white()),
@@ -216,7 +209,7 @@ pub async fn start(cli: crate::Cli) -> std::io::Result<()> {
}
let jwt_secret = config.auth.jwt_secret.clone();
let app_state = AppState::new(trusted_ip, config.clone(), db, jwt_secret);
let app_state = AppState::new(config.clone(), db, jwt_secret);
let rate_limit_state = RateLimitState::new();
// Create GURT server

View File

@@ -1,6 +1,7 @@
use super::{models::*, AppState};
use crate::auth::Claims;
use crate::discord_bot::{send_domain_approval_request, DomainRegistration};
use base64::{engine::general_purpose, Engine as _};
use gurt::prelude::*;
use rand::{rngs::OsRng, Rng};
use sha2::{Digest, Sha256};
@@ -1101,7 +1102,7 @@ fn generate_challenge_data(domain: &str, token: &str) -> Result<String> {
let mut rng = OsRng;
let random_bytes: [u8; 32] = rng.gen();
let secure_entropy = base64::encode(random_bytes);
let secure_entropy = general_purpose::STANDARD.encode(random_bytes);
let uuid_entropy = uuid::Uuid::new_v4().to_string();
@@ -1113,7 +1114,7 @@ fn generate_challenge_data(domain: &str, token: &str) -> Result<String> {
hasher.update(data.as_bytes());
let hash = hasher.finalize();
Ok(base64::encode(hash))
Ok(general_purpose::STANDARD.encode(hash))
}
#[derive(serde::Serialize)]