mirror of https://github.com/zer0bin-dev/zer0bin
config tings
This commit is contained in:
parent
853ffaecca
commit
a236567307
|
@ -1,2 +1,5 @@
|
|||
**/target/
|
||||
**/node_modules/
|
||||
**/dist/
|
||||
**/.parcel-cache/
|
||||
config.json
|
|
@ -40,10 +40,10 @@ Submit your public instance [here](https://github.com/Domterion/zer0bin/issues/n
|
|||
|
||||
### Requirements
|
||||
|
||||
- Rust >= 1.58.0
|
||||
- Postgresql >= 12.0
|
||||
- Nginx >= 1.18.0
|
||||
- \*nix OS
|
||||
- Rust >= 1.58.0
|
||||
- Postgresql >= 12.0
|
||||
- Nginx >= 1.18.0
|
||||
- \*nix OS
|
||||
|
||||
### Steps
|
||||
|
||||
|
@ -66,6 +66,7 @@ Submit your public instance [here](https://github.com/Domterion/zer0bin/issues/n
|
|||
| server.backend_port | Any open port | The port to run the backend on |
|
||||
| pastes.character_limit | Number up to 2^64 - 1 | The amount of characters allowed in a single paste |
|
||||
| pastes.days_til_expiration | Number up to 2^63 or -1 | The days till a paste is to expire. If set to -1 then pastes will never expire |
|
||||
| pastes.id_length | Number up to 2^64 - 1 | The length of the ID for each paste |
|
||||
| databases.postgres_uri | PostreSQL Connection URI | The URI to use when connecting to a PostgreSQL database |
|
||||
| ratelimits.pastes_per_second | Number up to 2^64 - 1 | The amount of pastes allowed per second |
|
||||
| ratelimits.pastes_burst | Number up to 2^32 - 1 | Amount of requests that can be made before they are blocked and have to wait |
|
||||
|
|
|
@ -18,14 +18,15 @@ pub struct ServerConfig {
|
|||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct RatelimitsConifg {
|
||||
pub pastes_per_second: u64,
|
||||
pub pastes_burst: u32
|
||||
pub seconds_in_between_pastes: u64,
|
||||
pub allowed_pastes_before_ratelimit: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct PastesConfig {
|
||||
pub character_limit: usize,
|
||||
pub days_til_expiration: i64,
|
||||
pub id_length: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
|
|
|
@ -122,7 +122,8 @@ async fn new_paste(state: web::Data<AppState>, data: web::Json<PartialPaste>) ->
|
|||
});
|
||||
}
|
||||
|
||||
let id = nanoid!(10);
|
||||
let length = state.config.pastes.id_length;
|
||||
let id = nanoid!(length);
|
||||
|
||||
let expires_at = if state.config.pastes.days_til_expiration == -1 {
|
||||
None
|
||||
|
@ -174,8 +175,8 @@ async fn main() -> io::Result<()> {
|
|||
);
|
||||
|
||||
let paste_governor = GovernorConfigBuilder::default()
|
||||
.per_second(config.ratelimits.pastes_per_second)
|
||||
.burst_size(config.ratelimits.pastes_burst)
|
||||
.per_second(config.ratelimits.seconds_in_between_pastes)
|
||||
.burst_size(config.ratelimits.allowed_pastes_before_ratelimit)
|
||||
.finish()
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
},
|
||||
"pastes": {
|
||||
"character_limit": 40000,
|
||||
"days_til_expiration": 7
|
||||
"days_til_expiration": 7,
|
||||
"id_length": 10
|
||||
},
|
||||
"ratelimits": {
|
||||
"pastes_per_second": 2,
|
||||
"pastes_burst": 5
|
||||
"seconds_in_between_pastes": 2,
|
||||
"allowed_pastes_before_ratelimit": 5
|
||||
},
|
||||
"databases": {
|
||||
"postgres_uri": "postgres://postgres:postgres@localhost:5432/zer0bin"
|
||||
|
|
Loading…
Reference in New Issue