2023-07-02 19:59:25 +02:00
|
|
|
extern crate rand;
|
2023-07-02 20:18:43 +02:00
|
|
|
extern crate rouille;
|
2023-07-02 19:59:25 +02:00
|
|
|
|
2023-07-15 14:21:49 +02:00
|
|
|
use std::sync::Arc;
|
2023-07-02 19:59:25 +02:00
|
|
|
use std::thread;
|
|
|
|
|
|
|
|
mod http;
|
|
|
|
mod random_names;
|
|
|
|
mod smtp;
|
2023-07-02 20:18:43 +02:00
|
|
|
mod state;
|
2023-07-02 19:59:25 +02:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
println!("Starting on localhost:8005");
|
|
|
|
|
|
|
|
let state = state::fresh_state();
|
|
|
|
|
2023-07-15 14:21:49 +02:00
|
|
|
let http_state = Arc::clone(&state);
|
|
|
|
let http_thread = thread::spawn(move || {
|
2023-07-02 19:59:25 +02:00
|
|
|
rouille::start_server("localhost:8005", move |request| {
|
2023-07-15 14:21:49 +02:00
|
|
|
http::http_handler(request, &http_state)
|
2023-07-02 19:59:25 +02:00
|
|
|
})
|
|
|
|
});
|
|
|
|
|
2023-07-15 14:21:49 +02:00
|
|
|
let smtp_state = Arc::clone(&state);
|
|
|
|
let smtp_thread = thread::spawn(move || {
|
|
|
|
smtp::start_server(smtp_state);
|
2023-07-02 19:59:25 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
http_thread.join().unwrap();
|
|
|
|
smtp_thread.join().unwrap();
|
|
|
|
}
|