46 lines
1.5 KiB
Rust
46 lines
1.5 KiB
Rust
/*
|
|
* mCaptcha - A proof of work based DoS protection system
|
|
* Copyright © 2023 Aravinth Manivannan <realravinth@batsense.net>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
use std::sync::Arc;
|
|
|
|
use actix::prelude::*;
|
|
use libmcaptcha::{
|
|
cache::{hashcache::HashCache, messages::VerifyCaptchaResult},
|
|
master::embedded::master::Master,
|
|
master::messages::AddSiteBuilder,
|
|
pow::{ConfigBuilder, Work},
|
|
system::{System, SystemBuilder},
|
|
DefenseBuilder, LevelBuilder, MCaptchaBuilder,
|
|
};
|
|
|
|
pub fn init_system(salt: String) -> Arc<System<HashCache, Master>> {
|
|
let cache = HashCache::default().start();
|
|
|
|
let pow = ConfigBuilder::default().salt(salt).build().unwrap();
|
|
|
|
let master = Master::new(5).start();
|
|
|
|
let system = SystemBuilder::default()
|
|
.master(master)
|
|
.cache(cache)
|
|
.pow(pow.clone())
|
|
.runners(4)
|
|
.queue_length(2000)
|
|
.build();
|
|
Arc::new(system)
|
|
}
|