Skip to content

Commit

Permalink
Fix error in fallback IP address
Browse files Browse the repository at this point in the history
  • Loading branch information
cndolo committed Jan 17, 2024
1 parent ab5d354 commit b5fe23c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions network-parser/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use log::error;
use serde::{Deserialize, Deserializer};
use serde_aux::prelude::*;
use std::hash::{Hash, Hasher};
use std::net::SocketAddr;
use std::str::FromStr;
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
str::FromStr,
};

use crate::*;

Expand Down Expand Up @@ -350,7 +352,7 @@ fn parse_net_address(addr: &str) -> String {
if !addr.contains("onion") {
let sock_addr: SocketAddr = addr.parse().unwrap_or_else(|_| {
error!("Failed to parse {:#?} as IpAddr", addr);
FromStr::from_str("0.0.0.0").unwrap()
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0)
});
sock_addr.ip().to_string()
} else {
Expand Down

0 comments on commit b5fe23c

Please sign in to comment.