Skip to content

Commit

Permalink
fix: Remove local_ip retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 4, 2023
1 parent 3ea6e66 commit ff8e599
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 72 deletions.
38 changes: 0 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions backend/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,6 @@
"x-stoplight": {
"id": "ld3cp67qd2nx8"
}
},
"server_name": {
"type": "string",
"x-stoplight": {
"id": "yy9pz1lxrr4si"
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fantoccini = { version = "0.19.3", optional = true }
futures = { version = "0.3.29", optional = true }
fast-socks5 = "0.9.1"
levenshtein = "1.0.5"
local-ip-address = "0.5.6"
log = "0.4.20"
mailchecker = "6.0.1"
md5 = "0.7.0"
Expand Down
28 changes: 1 addition & 27 deletions core/src/util/input_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::env;
use std::net::IpAddr;
use std::str::FromStr;
use std::time::{Duration, SystemTime};

use async_smtp::{ClientSecurity, ClientTlsParameters};
use chrono::{DateTime, Utc};
use local_ip_address::{local_ip, Error as LocalIpError};
use serde::{ser::SerializeMap, Deserialize, Serialize, Serializer};

use crate::misc::{MiscDetails, MiscError};
Expand Down Expand Up @@ -429,13 +427,11 @@ pub enum Reachable {
}

/// Details about the email verification used for debugging.
#[derive(Debug)]
#[derive(Debug, Deserialize, Serialize)]
pub struct DebugDetails {
/// The name of the server that performed the email verification.
/// It's generally passed as an environment variable RCH_BACKEND_NAME.
pub server_name: String,
/// The IP address of the server that performed the email verification.
pub server_ip: Result<IpAddr, LocalIpError>,
/// The time when the email verification started.
pub start_time: DateTime<Utc>,
/// The time when the email verification ended.
Expand All @@ -444,35 +440,13 @@ pub struct DebugDetails {
pub duration: Duration,
}

impl Serialize for DebugDetails {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut map = serializer.serialize_map(Some(4))?;
map.serialize_entry("start_time", &self.start_time)?;
map.serialize_entry("end_time", &self.end_time)?;
map.serialize_entry("duration", &self.duration)?;
map.serialize_entry(
"server_ip",
&match &self.server_ip {
Ok(ip) => ip.to_string(),
Err(e) => e.to_string(),
},
)?;
map.serialize_entry("server_name", &self.server_name)?;
map.end()
}
}

impl Default for DebugDetails {
fn default() -> Self {
Self {
server_name: env::var("RCH_BACKEND_NAME").unwrap_or_else(|_| String::new()),
start_time: SystemTime::now().into(),
end_time: SystemTime::now().into(),
duration: Duration::default(),
server_ip: local_ip(),
}
}
}
Expand Down

0 comments on commit ff8e599

Please sign in to comment.