mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-12-22 16:26:28 +00:00
commit
0c01866344
503
Cargo.lock
generated
503
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -18,4 +18,6 @@ serde_json = "1"
|
|||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
ring = "0.16"
|
ring = "0.16"
|
||||||
bs62 = "0.1"
|
bs62 = "0.1"
|
||||||
memcache = "0.15"
|
memcache = "0.16"
|
||||||
|
byte-unit = "4"
|
||||||
|
mime = "0.3"
|
||||||
|
@ -36,6 +36,13 @@ each note has a 512bit generated <i>id</i> that is used to retrieve the note. da
|
|||||||
|
|
||||||
![screenshot](./design/Screens.png)
|
![screenshot](./design/Screens.png)
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
| ------------ | ----------------- | --------------------------------------------------------------------------------------- |
|
||||||
|
| `MEMCACHE` | `memcached:11211` | Memcached URL to connect to. |
|
||||||
|
| `SIZE_LIMIT` | `1 KiB` | Max size for body. Accepted values according to [byte-unit](https://docs.rs/byte-unit/) |
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
ℹ️ `https` is required otherwise browsers will not support the cryptographic functions.
|
ℹ️ `https` is required otherwise browsers will not support the cryptographic functions.
|
||||||
@ -115,7 +122,7 @@ Running `npm run dev` in the root folder will start the following things
|
|||||||
- rust backend with hot reload
|
- rust backend with hot reload
|
||||||
- client with hot reload
|
- client with hot reload
|
||||||
|
|
||||||
You can see the app under [localhost:3000](http://localhost:3000).
|
You can see the app under [localhost:5000](http://localhost:5000).
|
||||||
|
|
||||||
###### Attributions
|
###### Attributions
|
||||||
|
|
||||||
|
13
src/main.rs
13
src/main.rs
@ -5,19 +5,28 @@ extern crate lazy_static;
|
|||||||
|
|
||||||
mod client;
|
mod client;
|
||||||
mod note;
|
mod note;
|
||||||
|
mod size;
|
||||||
mod store;
|
mod store;
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
HttpServer::new(|| {
|
return HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
|
// .configure(|cfg: &mut web::ServiceConfig| {
|
||||||
|
// let limit_string = std::env::var("SIZE_LIMIT").unwrap_or("0.1 KiB".to_string());
|
||||||
|
// let limit = Byte::from_str(limit_string.clone()).unwrap().get_bytes() as usize;
|
||||||
|
// println!("SIZE_LIMIT: {}, {}", limit_string, limit);
|
||||||
|
// let config = web::JsonConfig::default().limit(limit);
|
||||||
|
// cfg.data(config);
|
||||||
|
// })
|
||||||
.wrap(middleware::Compress::default())
|
.wrap(middleware::Compress::default())
|
||||||
.wrap(middleware::DefaultHeaders::default())
|
.wrap(middleware::DefaultHeaders::default())
|
||||||
|
.configure(size::init)
|
||||||
.configure(note::init)
|
.configure(note::init)
|
||||||
.configure(client::init)
|
.configure(client::init)
|
||||||
.default_service(web::resource("").route(web::get().to(client::fallback_fn)))
|
.default_service(web::resource("").route(web::get().to(client::fallback_fn)))
|
||||||
})
|
})
|
||||||
.bind("0.0.0.0:5000")?
|
.bind("0.0.0.0:5000")?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,6 @@ async fn create(note: web::Json<Note>) -> impl Responder {
|
|||||||
let mut n = note.into_inner();
|
let mut n = note.into_inner();
|
||||||
let id = generate_id();
|
let id = generate_id();
|
||||||
let bad_req = HttpResponse::BadRequest().finish();
|
let bad_req = HttpResponse::BadRequest().finish();
|
||||||
if n.contents.chars().count() > 8192 {
|
|
||||||
return bad_req;
|
|
||||||
}
|
|
||||||
if n.views == None && n.expiration == None {
|
if n.views == None && n.expiration == None {
|
||||||
return bad_req;
|
return bad_req;
|
||||||
}
|
}
|
||||||
|
10
src/size.rs
Normal file
10
src/size.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
use actix_web::web;
|
||||||
|
use byte_unit::Byte;
|
||||||
|
|
||||||
|
pub fn init(cfg: &mut web::ServiceConfig) {
|
||||||
|
let limit_string = std::env::var("SIZE_LIMIT").unwrap_or("1 KiB".to_string());
|
||||||
|
let limit = Byte::from_str(limit_string.clone()).unwrap().get_bytes() as usize;
|
||||||
|
println!("SIZE_LIMIT: {}, {}", limit_string, limit);
|
||||||
|
let config = web::JsonConfig::default().limit(limit);
|
||||||
|
cfg.data(config);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user