Antispam
This commit is contained in:
parent
096390d533
commit
9fd7514927
7 changed files with 204 additions and 19 deletions
|
|
@ -8,10 +8,18 @@ const CONFIG_FILE: &str = "config.toml";
|
|||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Config {
|
||||
//#[serde(default = "Config::default_admin_emails")]
|
||||
//pub admin_emails: Vec<String>,
|
||||
#[serde(default = "Config::default_admin_passwords")]
|
||||
pub admin_passwords: Vec<String>,
|
||||
/// (seconds)
|
||||
#[serde(default = "Config::default_antispam_duration")]
|
||||
pub antispam_duration: u64,
|
||||
#[serde(default = "Config::default_antispam_enable")]
|
||||
pub antispam_enable: bool,
|
||||
/// Maximum number of mutations by IP within antispam_duration
|
||||
#[serde(default = "Config::default_antispam_mutation_limit")]
|
||||
pub antispam_mutation_limit: u32,
|
||||
#[serde(default = "Config::default_antispam_whitelist")]
|
||||
pub antispam_whitelist: Vec<IpAddr>,
|
||||
/// New or edited comments need admin's approval before being public
|
||||
#[serde(default = "Config::default_comment_approve")]
|
||||
pub comment_approve: bool,
|
||||
|
|
@ -43,17 +51,30 @@ pub struct Config {
|
|||
pub matrix_server: String,
|
||||
#[serde(default = "Config::default_matrix_user")]
|
||||
pub matrix_user: String,
|
||||
/// Are we behind a reverse proxy?
|
||||
/// Determines whether we assume client address is in a Forwarded header or socket address.
|
||||
#[serde(default = "Config::default_reverse_proxy")]
|
||||
pub reverse_proxy: bool,
|
||||
#[serde(default = "Config::default_root_url")]
|
||||
pub root_url: String,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
/*fn default_admin_emails() -> Vec<String> {
|
||||
vec![]
|
||||
}*/
|
||||
fn default_admin_passwords() -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
fn default_antispam_duration() -> u64 {
|
||||
3600
|
||||
}
|
||||
fn default_antispam_enable() -> bool {
|
||||
true
|
||||
}
|
||||
fn default_antispam_mutation_limit() -> u32 {
|
||||
10
|
||||
}
|
||||
fn default_antispam_whitelist() -> Vec<IpAddr> {
|
||||
vec![[127u8, 0, 0, 1].into(), [0u8; 4].into(), [0u8; 16].into()]
|
||||
}
|
||||
fn default_comment_approve() -> bool {
|
||||
true
|
||||
}
|
||||
|
|
@ -96,6 +117,9 @@ impl Config {
|
|||
fn default_matrix_user() -> String {
|
||||
"@tuxmain:matrix.txmn.tk".into()
|
||||
}
|
||||
fn default_reverse_proxy() -> bool {
|
||||
false
|
||||
}
|
||||
fn default_root_url() -> String {
|
||||
"/".into()
|
||||
}
|
||||
|
|
@ -104,8 +128,11 @@ impl Config {
|
|||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
//admin_emails: Self::default_admin_emails(),
|
||||
admin_passwords: Self::default_admin_passwords(),
|
||||
antispam_duration: Self::default_antispam_duration(),
|
||||
antispam_enable: Self::default_antispam_enable(),
|
||||
antispam_mutation_limit: Self::default_antispam_mutation_limit(),
|
||||
antispam_whitelist: Self::default_antispam_whitelist(),
|
||||
comment_approve: Self::default_comment_approve(),
|
||||
comment_edit_timeout: Self::default_comment_edit_timeout(),
|
||||
comment_author_max_len: Self::default_comment_author_max_len(),
|
||||
|
|
@ -120,6 +147,7 @@ impl Default for Config {
|
|||
matrix_room: Self::default_matrix_room(),
|
||||
matrix_server: Self::default_matrix_server(),
|
||||
matrix_user: Self::default_matrix_user(),
|
||||
reverse_proxy: Self::default_reverse_proxy(),
|
||||
root_url: Self::default_root_url(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue