Skip to content

Commit

Permalink
Refactor scheme_host_port function to simplify HTTP/2 handling
Browse files Browse the repository at this point in the history
  • Loading branch information
arloor committed Sep 19, 2024
1 parent a5394e3 commit 21242de
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions rust_http_proxy/src/ip_x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn local_ip() -> io::Result<String> {
})
.collect::<Vec<_>>();

all_interfaces
let result = all_interfaces
.iter()
.find(|interface| {
interface.is_up() && !interface.is_loopback() && !interface.ips.is_empty()
Expand All @@ -64,9 +64,11 @@ pub fn local_ip() -> io::Result<String> {
.iter()
.find(|ip| ip.is_ipv4())
.map(|ip| ip.ip().to_string())
.unwrap()
})
.ok_or(io::Error::new(io::ErrorKind::NotFound, "No local ip found"))
});
match result {
Some(ip) => ip.ok_or(io::Error::new(io::ErrorKind::NotFound, "No ipv4 found")),
None => Err(io::Error::new(io::ErrorKind::NotFound, "No ip found")),
}
}

pub struct SocketAddrFormat<'a>(pub &'a std::net::SocketAddr);
Expand Down

0 comments on commit 21242de

Please sign in to comment.