diff options
author | ache <ache@ache.one> | 2022-12-10 08:36:25 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2022-12-10 08:51:29 +0100 |
commit | 68b15034815986665d27c08990c7a5cfdfadba21 (patch) | |
tree | aa3882550c9848a3961f63e3732e0dcf97c6c1d5 | |
parent | Don't likes by default (diff) |
Implement proxy
-rw-r--r-- | src/main.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 17e07f7..c7a128f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use std::{thread, time::Duration}; use std::sync::Arc; use std::fs; +use hyper::header; use serde_derive::{Serialize, Deserialize}; use toml; @@ -49,6 +50,14 @@ fn handle(req: Request<Body>, addr: SocketAddr, tx: Sender<VustMessage>, config: let path: String = req.uri().path().to_string(); + let addr = match req.headers().contains_key("real-ip") { + false => addr, + true => { + let string_ip = req.headers().get("real-ip").unwrap().to_str().unwrap(); + string_ip.parse().expect("Unable to parse IP address") + } + }; + let query_type = match *req.method() { Method::POST => VustQuery::Like, Method::PUT => VustQuery::Commit, |