Skip to content

Commit

Permalink
simplify parser
Browse files Browse the repository at this point in the history
  • Loading branch information
grooviegermanikus committed Sep 22, 2024
1 parent 8f797a2 commit 0b10ea0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The `net_utils` module assists with networking
#![allow(clippy::arithmetic_side_effects)]

use std::net::Ipv6Addr;
use std::str::FromStr;
use {
crossbeam_channel::unbounded,
log::*,
Expand Down Expand Up @@ -341,6 +344,12 @@ pub fn parse_port_range(port_range: &str) -> Option<PortRange> {
}

pub fn parse_host(host: &str) -> Result<IpAddr, String> {

println!("SKIP CHECK: HOST={}", host);
if true {
return Ok(SocketAddr::from_str(&format!("{}:0", host)).expect("valid IP").ip());
}

// First, check if the host syntax is valid. This check is needed because addresses
// such as `("localhost:1234", 0)` will resolve to IPs on some networks.
let parsed_url = Url::parse(&format!("http://{host}")).map_err(|e| e.to_string())?;
Expand Down

0 comments on commit 0b10ea0

Please sign in to comment.