Rodolphe Bréard
4 weeks ago
Failed to extract signature
4 changed files with
5 additions and
24 deletions
-
config/20_letsencrypt.toml
-
man/en/acmed.toml.5
-
src/config.rs
-
src/config/rate_limit.rs
|
|
@ -1,14 +1,13 @@ |
|
|
|
[[rate-limit]] |
|
|
|
name = "Let's Encrypt rate-limit" |
|
|
|
[[rate-limit."letsencrypt-v2"]] |
|
|
|
number = 20 |
|
|
|
period = "1s" |
|
|
|
|
|
|
|
[endpoint."letsencrypt-v2-production"] |
|
|
|
url = "https://acme-v02.api.letsencrypt.org/directory" |
|
|
|
rate_limits = ["Let's Encrypt rate-limit"] |
|
|
|
rate_limits = ["letsencrypt-v2"] |
|
|
|
tos_agreed = false |
|
|
|
|
|
|
|
[endpoint."letsencrypt-v2-staging"] |
|
|
|
url = "https://acme-staging-v02.api.letsencrypt.org/directory" |
|
|
|
rate_limits = ["Let's Encrypt rate-limit"] |
|
|
|
rate_limits = ["letsencrypt-v2"] |
|
|
|
tos_agreed = false |
|
|
@ -381,10 +381,8 @@ post-operation |
|
|
|
.El |
|
|
|
.El |
|
|
|
.It Ic rate-limit |
|
|
|
Array of table where each element defines a HTTPS rate limit. |
|
|
|
Table of table where each element defines a HTTPS rate limit. |
|
|
|
.Bl -tag |
|
|
|
.It Cm name Ar string |
|
|
|
The name the rate limit is registered under. Must be unique. |
|
|
|
.It Cm number Ar integer |
|
|
|
Number of requests authorized withing the time period. |
|
|
|
.It Cm period Ar string |
|
|
|
|
|
@ -30,7 +30,7 @@ pub struct AcmedConfig { |
|
|
|
#[serde(default)]
|
|
|
|
pub(in crate::config) endpoint: HashMap<String, Endpoint>,
|
|
|
|
#[serde(default, rename = "rate-limit")]
|
|
|
|
pub(in crate::config) rate_limit: Vec<RateLimit>,
|
|
|
|
pub(in crate::config) rate_limit: HashMap<String, RateLimit>,
|
|
|
|
#[serde(default)]
|
|
|
|
pub(in crate::config) hook: Vec<Hook>,
|
|
|
|
#[serde(default)]
|
|
|
|
|
|
@ -4,7 +4,6 @@ use serde_derive::Deserialize; |
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
#[serde(deny_unknown_fields)]
|
|
|
|
pub struct RateLimit {
|
|
|
|
pub(in crate::config) name: String,
|
|
|
|
pub(in crate::config) number: usize,
|
|
|
|
pub(in crate::config) period: Duration,
|
|
|
|
}
|
|
|
@ -23,32 +22,18 @@ mod tests { |
|
|
|
#[test]
|
|
|
|
fn ok() {
|
|
|
|
let cfg = r#"
|
|
|
|
name = "test"
|
|
|
|
number = 20
|
|
|
|
period = "20s"
|
|
|
|
"#;
|
|
|
|
|
|
|
|
let rl: RateLimit = load_str(cfg).unwrap();
|
|
|
|
assert_eq!(rl.name, "test");
|
|
|
|
assert_eq!(rl.number, 20);
|
|
|
|
assert_eq!(rl.period, Duration::from_secs(20));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn missing_name() {
|
|
|
|
let cfg = r#"
|
|
|
|
number = 20
|
|
|
|
period = "20s"
|
|
|
|
"#;
|
|
|
|
|
|
|
|
let res = load_str::<RateLimit>(cfg);
|
|
|
|
assert!(res.is_err());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn missing_number() {
|
|
|
|
let cfg = r#"
|
|
|
|
name = "test"
|
|
|
|
period = "20s"
|
|
|
|
"#;
|
|
|
|
|
|
|
@ -59,7 +44,6 @@ period = "20s" |
|
|
|
#[test]
|
|
|
|
fn missing_period() {
|
|
|
|
let cfg = r#"
|
|
|
|
name = "test"
|
|
|
|
number = 20
|
|
|
|
"#;
|
|
|
|
|
|
|
|