From 68b15034815986665d27c08990c7a5cfdfadba21 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 10 Dec 2022 08:36:25 +0100 Subject: Implement proxy --- src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) 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, addr: SocketAddr, tx: Sender, 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, -- cgit v1.2.3