Skip to content

Commit

Permalink
Minor logging fixes. Don't show alt-svg on HTTP/3
Browse files Browse the repository at this point in the history
  • Loading branch information
Icelk committed Jul 19, 2023
1 parent 541d7bb commit 2e7fc1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ impl RunConfig {
.bind(&address.into())
.expect("Failed to bind address");

info!("tcp {tcp}, addr {address:?}");

// wrap listener
#[cfg(feature = "http3")]
if !tcp {
Expand Down Expand Up @@ -552,11 +550,16 @@ async fn accept(
shutdown_manager: &Arc<shutdown::Manager>,
first: bool,
) -> Result<(), io::Error> {
let local_addr = listener.get_inner().local_addr();
let local_addr = listener.inner().local_addr();
if first {
info!(
"Started listening on port {} using {}",
"Started listening on port {} using {}/{}",
local_addr.port(),
if listener.inner().is_tcp() {
"TCP"
} else {
"QUIC"
},
if local_addr.is_ipv4() { "IPv4" } else { "IPv6" }
);
}
Expand Down Expand Up @@ -817,7 +820,7 @@ pub async fn handle_connection(
let mut response = handle_cache(&mut request, address, host).await;

#[cfg(any(feature = "http2", feature = "http3"))]
if secure {
if secure && version != Version::HTTP_3 {
response.response.headers_mut().append(
HeaderName::from_static("alt-svc"),
HeaderValue::from_maybe_shared(alt_svc_header).unwrap(),
Expand Down
5 changes: 4 additions & 1 deletion src/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ pub(crate) enum Listener {
Udp(h3_quinn::Endpoint),
}
impl Listener {
pub(crate) fn is_tcp(&self) -> bool {
matches!(self, Self::Tcp(_))
}
pub(crate) fn local_addr(&self) -> SocketAddr {
match self {
Listener::Tcp(tcp) => tcp.local_addr(),
Expand Down Expand Up @@ -452,7 +455,7 @@ impl AcceptManager {
}
/// Returns a reference to the inner listener.
#[must_use]
pub(crate) fn get_inner(&self) -> &Listener {
pub(crate) fn inner(&self) -> &Listener {
&self.listener
}
}
Expand Down

0 comments on commit 2e7fc1a

Please sign in to comment.