2018-12-25 21:35:04 +00:00
|
|
|
#![feature(proc_macro_hygiene, plugin, decl_macro)]
|
2018-08-16 18:35:19 +00:00
|
|
|
#![recursion_limit = "1024"]
|
|
|
|
#![feature(try_from)]
|
|
|
|
|
|
|
|
extern crate serde;
|
2019-02-07 19:58:31 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
2018-08-16 18:35:19 +00:00
|
|
|
extern crate serde_json;
|
|
|
|
|
2019-02-07 19:58:31 +00:00
|
|
|
extern crate hex;
|
2018-08-16 18:35:19 +00:00
|
|
|
extern crate time;
|
2018-10-24 17:45:11 +00:00
|
|
|
extern crate url;
|
2018-09-19 20:24:38 +00:00
|
|
|
|
2019-02-07 19:58:31 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate rocket;
|
2018-08-16 18:35:19 +00:00
|
|
|
extern crate multipart;
|
2019-02-07 19:58:31 +00:00
|
|
|
extern crate rocket_contrib;
|
2018-09-19 20:24:38 +00:00
|
|
|
|
2018-11-25 14:03:27 +00:00
|
|
|
extern crate sequoia_openpgp;
|
2019-02-07 19:58:31 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate error_chain;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
|
|
|
extern crate base64;
|
|
|
|
extern crate handlebars;
|
2018-11-02 10:50:57 +00:00
|
|
|
extern crate lettre;
|
|
|
|
extern crate lettre_email;
|
2019-02-07 19:58:31 +00:00
|
|
|
extern crate parking_lot;
|
|
|
|
extern crate rand;
|
|
|
|
extern crate structopt;
|
|
|
|
extern crate tempfile;
|
2019-02-22 14:45:34 +00:00
|
|
|
extern crate pathdiff;
|
2018-08-16 18:35:19 +00:00
|
|
|
|
|
|
|
mod database;
|
2018-11-02 10:50:57 +00:00
|
|
|
mod mail;
|
2019-02-07 19:58:31 +00:00
|
|
|
mod types;
|
|
|
|
mod web;
|
2018-08-16 18:35:19 +00:00
|
|
|
|
|
|
|
mod errors {
|
2019-02-07 19:58:31 +00:00
|
|
|
error_chain! {
|
2018-08-16 18:35:19 +00:00
|
|
|
foreign_links {
|
|
|
|
Fmt(::std::fmt::Error);
|
|
|
|
Io(::std::io::Error);
|
|
|
|
Json(::serde_json::Error);
|
|
|
|
Persist(::tempfile::PersistError);
|
2018-09-19 20:24:38 +00:00
|
|
|
RktConfig(::rocket::config::ConfigError);
|
|
|
|
StringUtf8Error(::std::string::FromUtf8Error);
|
|
|
|
StrUtf8Error(::std::str::Utf8Error);
|
2018-10-24 17:45:11 +00:00
|
|
|
HexError(::hex::FromHexError);
|
2018-11-02 10:50:57 +00:00
|
|
|
SendmailError(::lettre::sendmail::error::Error);
|
2018-08-16 18:35:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
use errors::*;
|
|
|
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use structopt::StructOpt;
|
|
|
|
|
|
|
|
#[derive(Debug, StructOpt)]
|
2019-02-07 19:58:31 +00:00
|
|
|
#[structopt(
|
|
|
|
name = "garbage",
|
|
|
|
about = "Garbage Pile - The verifying OpenPGP key server."
|
|
|
|
)]
|
2018-09-19 20:24:38 +00:00
|
|
|
pub struct Opt {
|
|
|
|
/// More verbose output. Disabled when running as daemon.
|
2018-08-16 18:35:19 +00:00
|
|
|
#[structopt(short = "v", long = "verbose")]
|
2018-09-19 20:24:38 +00:00
|
|
|
verbose: bool,
|
|
|
|
/// Daemonize after startup.
|
2018-08-16 18:35:19 +00:00
|
|
|
#[structopt(short = "d", long = "daemon")]
|
|
|
|
daemon: bool,
|
|
|
|
/// Base directory
|
|
|
|
#[structopt(parse(from_os_str))]
|
|
|
|
base: PathBuf,
|
2018-09-19 20:24:38 +00:00
|
|
|
/// Port and address to listen on.
|
|
|
|
#[structopt(short = "l", long = "listen", default_value = "0.0.0.0:8080")]
|
2018-08-16 18:35:19 +00:00
|
|
|
listen: String,
|
2018-11-02 10:50:57 +00:00
|
|
|
/// FQDN of the server. Used in templates.
|
|
|
|
#[structopt(short = "D", long = "domain", default_value = "localhost")]
|
|
|
|
domain: String,
|
2019-02-07 19:58:31 +00:00
|
|
|
#[structopt(
|
|
|
|
short = "F",
|
|
|
|
long = "from",
|
|
|
|
default_value = "noreply@localhost"
|
|
|
|
)]
|
2019-01-09 12:35:47 +00:00
|
|
|
from: String,
|
2019-02-07 19:58:31 +00:00
|
|
|
}
|
2018-08-16 18:35:19 +00:00
|
|
|
|
|
|
|
fn main() {
|
2018-09-19 20:24:38 +00:00
|
|
|
use database::{Filesystem, Polymorphic};
|
|
|
|
|
2018-08-16 18:35:19 +00:00
|
|
|
let opt = Opt::from_args();
|
2018-09-19 20:24:38 +00:00
|
|
|
println!("{:#?}", opt);
|
|
|
|
|
|
|
|
if !opt.base.is_absolute() {
|
|
|
|
panic!("Base directory must be absolute");
|
|
|
|
}
|
2018-08-16 18:35:19 +00:00
|
|
|
|
2018-09-19 20:24:38 +00:00
|
|
|
let db = Filesystem::new(opt.base.clone()).unwrap();
|
|
|
|
web::serve(&opt, Polymorphic::Filesystem(db)).unwrap();
|
|
|
|
}
|