Skip to content

Commit 6071be2

Browse files
committed
feat: v18.0.0
1 parent 160ddae commit 6071be2

File tree

5 files changed

+12
-104
lines changed

5 files changed

+12
-104
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hyperlane"
3-
version = "17.3.7"
3+
version = "18.0.0"
44
readme = "README.md"
55
edition = "2024"
66
authors = ["root@ltpp.vip"]

src/context/impl.rs

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -321,105 +321,6 @@ impl Context {
321321
!self.get_closed() && keep_alive
322322
}
323323

324-
/// Retrieves the remote socket address of the connection.
325-
///
326-
/// # Returns
327-
///
328-
/// - `Option<SocketAddr>` - The socket address of the remote peer if available.
329-
pub async fn try_get_socket_addr(&self) -> Option<SocketAddr> {
330-
self.try_get_stream()
331-
.as_ref()?
332-
.read()
333-
.await
334-
.peer_addr()
335-
.ok()
336-
}
337-
338-
/// Retrieves the remote socket address.
339-
///
340-
/// # Returns
341-
///
342-
/// - `SocketAddr` - The socket address of the remote peer.
343-
///
344-
/// # Panics
345-
///
346-
/// - If the socket address is not found.
347-
pub async fn get_socket_addr(&self) -> SocketAddr {
348-
self.try_get_socket_addr().await.unwrap()
349-
}
350-
351-
/// Retrieves the remote socket address as a string.
352-
///
353-
/// # Returns
354-
///
355-
/// - `Option<String>` - The string representation of the socket address if available.
356-
pub async fn try_get_socket_addr_string(&self) -> Option<String> {
357-
self.try_get_socket_addr()
358-
.await
359-
.map(|data| data.to_string())
360-
}
361-
362-
/// Retrieves the remote socket address as a string.
363-
///
364-
/// # Returns
365-
///
366-
/// - `String` - The string representation of the socket address.
367-
///
368-
/// # Panics
369-
///
370-
/// - If the socket address is not found.
371-
pub async fn get_socket_addr_string(&self) -> String {
372-
self.get_socket_addr().await.to_string()
373-
}
374-
375-
/// Retrieves the IP address part of the remote socket address.
376-
///
377-
/// # Returns
378-
///
379-
/// - `Option<SocketHost>` - The IP address of the remote peer.
380-
pub async fn try_get_socket_host(&self) -> Option<SocketHost> {
381-
self.try_get_socket_addr()
382-
.await
383-
.map(|socket_addr: SocketAddr| socket_addr.ip())
384-
}
385-
386-
/// Retrieves the IP address part of the remote socket address.
387-
///
388-
/// # Returns
389-
///
390-
/// - `SocketHost` - The IP address of the remote peer.
391-
///
392-
/// # Panics
393-
///
394-
/// - If the socket address is not found.
395-
pub async fn get_socket_host(&self) -> SocketHost {
396-
self.try_get_socket_host().await.unwrap()
397-
}
398-
399-
/// Retrieves the port number part of the remote socket address.
400-
///
401-
/// # Returns
402-
///
403-
/// - `Option<SocketPort>` - The port number of the remote peer if available.
404-
pub async fn try_get_socket_port(&self) -> Option<SocketPort> {
405-
self.try_get_socket_addr()
406-
.await
407-
.map(|socket_addr: SocketAddr| socket_addr.port())
408-
}
409-
410-
/// Retrieves the port number part of the remote socket address.
411-
///
412-
/// # Returns
413-
///
414-
/// - `SocketPort` - The port number of the remote peer.
415-
///
416-
/// # Panics
417-
///
418-
/// - If the socket address is not found.
419-
pub async fn get_socket_port(&self) -> SocketPort {
420-
self.try_get_socket_port().await.unwrap()
421-
}
422-
423324
/// Attempts to retrieve a specific route parameter by its name.
424325
///
425326
/// # Arguments

src/context/struct.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ pub struct Context {
1313
#[get(type(copy))]
1414
pub(super) closed: bool,
1515
/// The underlying network stream for the connection.
16-
#[get(pub(crate))]
1716
#[get_mut(skip)]
18-
#[set(pub(crate))]
17+
#[set(pub(super))]
1918
pub(super) stream: Option<ArcRwLockStream>,
2019
/// The incoming HTTP request.
2120
#[get_mut(skip)]

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use std::{
3131
future::Future,
3232
hash::{Hash, Hasher},
3333
io::{self, Write, stderr, stdout},
34-
net::SocketAddr,
3534
pin::Pin,
3635
sync::{Arc, OnceLock},
3736
};

src/server/test.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,16 @@ struct RequestMiddleware {
222222

223223
impl ServerHook for RequestMiddleware {
224224
async fn new(ctx: &mut Context) -> Self {
225-
let socket_addr: String = ctx.get_socket_addr_string().await;
225+
let mut socket_addr: String = String::new();
226+
if let Some(stream) = ctx.try_get_stream().as_ref() {
227+
socket_addr = stream
228+
.read()
229+
.await
230+
.peer_addr()
231+
.ok()
232+
.map(|data| data.to_string())
233+
.unwrap_or_default();
234+
}
226235
Self { socket_addr }
227236
}
228237

0 commit comments

Comments
 (0)