Use constant Ipv4Addr::LOCALHOST

This commit is contained in:
David Bürgin 2020-04-12 11:19:51 +02:00
parent 65eeae374c
commit 6d54a6a5d1
2 changed files with 2 additions and 2 deletions

View file

@ -64,7 +64,7 @@ fn handle_connect(
_: &str, _: &str,
socket_addr: Option<SocketAddr>, socket_addr: Option<SocketAddr>,
) -> milter::Result<Status> { ) -> milter::Result<Status> {
let ip = socket_addr.map_or_else(|| IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), |a| a.ip()); let ip = socket_addr.map_or_else(|| IpAddr::V4(Ipv4Addr::LOCALHOST), |a| a.ip());
if config::get().use_trusted_networks() { if config::get().use_trusted_networks() {
if config::get().is_in_trusted_networks(&ip) { if config::get().is_in_trusted_networks(&ip) {

View file

@ -19,7 +19,7 @@ pub fn spawn_mock_spamd_server<F>(port: u16, f: F) -> JoinHandle<()>
where where
F: Fn(String) -> HamOrSpam + Send + 'static, F: Fn(String) -> HamOrSpam + Send + 'static,
{ {
let socket_addr = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), port); let socket_addr = SocketAddrV4::new(Ipv4Addr::LOCALHOST, port);
let timeout = Duration::from_secs(15); let timeout = Duration::from_secs(15);
thread::spawn(move || { thread::spawn(move || {