diff options
Diffstat (limited to 'src/main.rs')
-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, |