pub mod version;
pub mod websocket;
-use actix_web::HttpRequest;
+use actix_web::dev::ConnectionInfo;
use chrono::{DateTime, NaiveDateTime, Utc};
use isahc::prelude::*;
use lettre::smtp::authentication::{Credentials, Mechanism};
comrak::markdown_to_html(text, &comrak::ComrakOptions::default())
}
-pub fn get_ip(req: &HttpRequest) -> String {
- req
- .connection_info()
+pub fn get_ip(conn_info: &ConnectionInfo) -> String {
+ conn_info
.remote()
.unwrap_or("127.0.0.1:12345")
.split(':')
use super::{IPAddr, Settings};
use crate::api::APIError;
+use crate::get_ip;
use crate::settings::RateLimitConfig;
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
use failure::Error;
}
fn call(&mut self, req: S::Request) -> Self::Future {
- let ip_addr = req
- .connection_info()
- .remote()
- .unwrap_or("127.0.0.1:12345")
- .split(':')
- .next()
- .unwrap_or("127.0.0.1")
- .to_string();
+ let ip_addr = get_ip(&req.connection_info());
let fut = self
.rate_limited
cs_addr: chat_server.get_ref().to_owned(),
id: 0,
hb: Instant::now(),
- ip: get_ip(&req),
+ ip: get_ip(&req.connection_info()),
},
&req,
stream,