Skip to content

Commit da125a6

Browse files
committed
More aggressively rate limit reserving new package names
Larger burst limits can be applied on a per-user basis if they contact us ahead of time.
1 parent b5f3440 commit da125a6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/publish_rate_limit.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,19 @@ pub struct PublishRateLimit {
1414

1515
impl Default for PublishRateLimit {
1616
fn default() -> Self {
17+
let minutes = dotenv::var("WEB_NEW_PKG_RATE_LIMIT_RATE_MINUTES")
18+
.unwrap_or_default()
19+
.parse()
20+
.ok()
21+
.unwrap_or(10);
22+
let burst = dotenv::var("WEB_NEW_PKG_RATE_LIMIT_BURST")
23+
.unwrap_or_default()
24+
.parse()
25+
.ok()
26+
.unwrap_or(5);
1727
Self {
18-
rate: Duration::from_secs(60) * 10,
19-
burst: 30,
28+
rate: Duration::from_secs(60) * minutes,
29+
burst,
2030
}
2131
}
2232
}

0 commit comments

Comments
 (0)