v0.34.0_10
This commit is contained in:
1 parent
8c4cbc583f
commit
dd2502dd11
13 files changed
+389
-113
No files matched your search
@@ -0,0 +1,29 @@
|
||||
/// Immutable formatting shared by all HTTP/1 requests on one accepted socket.
|
||||
/// No routing or trust decision is cached: those follow the current snapshot.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct PeerFormatting {
|
||||
peer: SocketAddr,
|
||||
local: SocketAddr,
|
||||
peer_ip: IpAddr,
|
||||
peer_header: HeaderValue,
|
||||
peer_node: String,
|
||||
by_node: String,
|
||||
port_header: HeaderValue,
|
||||
}
|
||||
impl PeerFormatting {
|
||||
pub(crate) fn new(peer: SocketAddr, local: SocketAddr) -> Self {
|
||||
let peer_ip = canonical(peer.ip());
|
||||
let peer_text = peer_ip.to_string();
|
||||
Self {
|
||||
peer,
|
||||
local,
|
||||
peer_ip,
|
||||
peer_header: HeaderValue::from_str(&peer_text).expect("IP text is a valid header"),
|
||||
peer_node: if peer_ip.is_ipv4() { peer_text } else { node(peer_ip) },
|
||||
by_node: node(canonical(local.ip())),
|
||||
port_header: HeaderValue::from_str(&local.port().to_string())
|
||||
.expect("TCP port is a valid header"),
|
||||
}
|
||||
}
|
||||
fn peer_header(&self) -> &HeaderValue { &self.peer_header }
|
||||
}
|
||||
Reference in new issue
Block a user