Skip to content

Commit ffb8994

Browse files
committed
chore: release v0.2.3
chore: update deps
1 parent 6fa9384 commit ffb8994

4 files changed

Lines changed: 23 additions & 33 deletions

File tree

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "proxy-protocol-codec"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
edition = "2021"
55
rust-version = "1.77.0"
66

@@ -15,10 +15,10 @@ repository = "https://github.com/hanyu-dev/proxy-protocol-codec"
1515

1616
[dependencies]
1717
crc32c = { version = "0.6.8", default-features = false, optional = true }
18-
slicur = { version = "0.2.0", optional = true }
18+
slicur = { version = "0.3.0", optional = true }
1919
thiserror = { version = "2.0", optional = true }
20-
uni-addr = { version = "0.2.2", default-features = false, optional = true }
21-
wrapper-lite = { version = "0.1.1", default-features = false }
20+
uni-addr = { version = "0.3.1", default-features = false, optional = true }
21+
wrapper-lite = { version = "0.3.2", default-features = false }
2222

2323
[dev-dependencies]
2424
criterion = { version = "0.7.0", features = ["html_reports"] }
@@ -51,7 +51,7 @@ feat-nightly = []
5151
feat-codec-encode = ["feat-alloc", "dep:thiserror"]
5252

5353
# Enable decoding support.
54-
feat-codec-decode = ["dep:thiserror", "dep:slicur"]
54+
feat-codec-decode = ["dep:slicur", "dep:thiserror"]
5555

5656
# Enable the v1 codec support.
5757
feat-codec-v1 = []
@@ -66,7 +66,7 @@ feat-codec-v2-crc32c = ["feat-std", "dep:crc32c"]
6666
feat-uni-addr = ["feat-std", "dep:uni-addr"]
6767

6868
# Deprecated features.
69-
feat-codec-v2-uni-addr = ["feat-uni-addr"]
69+
feat-codec-v2-uni-addr = ["feat-uni-addr", "feat-std"]
7070

7171
[lints]
7272
clippy.allow_attributes_without_reason = "warn"

src/v1/model.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,31 +104,31 @@ impl AddressPair {
104104

105105
#[cfg(feature = "feat-uni-addr")]
106106
/// Returns the source address.
107-
pub fn src_uni_addr(&self) -> io::Result<Option<uni_addr::SocketAddr>> {
107+
pub fn src_uni_addr(&self) -> io::Result<Option<uni_addr::UniAddr>> {
108108
use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
109109

110110
match self {
111111
Self::Unspecified => Ok(None),
112-
Self::Inet { src_ip, src_port, .. } => Ok(Some(uni_addr::SocketAddr::Inet(SocketAddr::V4(
112+
Self::Inet { src_ip, src_port, .. } => Ok(Some(uni_addr::UniAddr::from(SocketAddr::V4(
113113
SocketAddrV4::new(*src_ip, *src_port),
114114
)))),
115-
Self::Inet6 { src_ip, src_port, .. } => Ok(Some(uni_addr::SocketAddr::Inet(SocketAddr::V6(
115+
Self::Inet6 { src_ip, src_port, .. } => Ok(Some(uni_addr::UniAddr::from(SocketAddr::V6(
116116
SocketAddrV6::new(*src_ip, *src_port, 0, 0),
117117
)))),
118118
}
119119
}
120120

121121
#[cfg(feature = "feat-uni-addr")]
122122
/// Returns the destination address.
123-
pub fn dst_uni_addr(&self) -> io::Result<Option<uni_addr::SocketAddr>> {
123+
pub fn dst_uni_addr(&self) -> io::Result<Option<uni_addr::UniAddr>> {
124124
use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
125125

126126
match self {
127127
Self::Unspecified => Ok(None),
128-
Self::Inet { dst_ip, dst_port, .. } => Ok(Some(uni_addr::SocketAddr::Inet(SocketAddr::V4(
128+
Self::Inet { dst_ip, dst_port, .. } => Ok(Some(uni_addr::UniAddr::from(SocketAddr::V4(
129129
SocketAddrV4::new(*dst_ip, *dst_port),
130130
)))),
131-
Self::Inet6 { dst_ip, dst_port, .. } => Ok(Some(uni_addr::SocketAddr::Inet(SocketAddr::V6(
131+
Self::Inet6 { dst_ip, dst_port, .. } => Ok(Some(uni_addr::UniAddr::from(SocketAddr::V6(
132132
SocketAddrV6::new(*dst_ip, *dst_port, 0, 0),
133133
)))),
134134
}

src/v2/codec/decode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ pub struct DecodedHeader<'a> {
270270
}
271271

272272
wrapper_lite::wrapper! {
273-
#[wrapper_impl(Deref)]
273+
#[wrapper_impl(Deref<[u8]>)]
274274
#[derive(Debug)]
275275
/// A wrapper around a slice of bytes representing the encoded extensions
276276
/// of the PROXY Protocol v2 header.
277277
///
278278
/// This implements `IntoIterator` to iterate over the extensions. See
279279
/// [`DecodedExtensionsIter`] for more details.
280-
pub DecodedExtensions<'a>(&'a [u8])
280+
pub struct DecodedExtensions<'a>(&'a [u8]);
281281
}
282282

283283
impl<'a> DecodedExtensions<'a> {

src/v2/model.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -201,51 +201,41 @@ impl AddressPair {
201201

202202
#[cfg(feature = "feat-uni-addr")]
203203
/// Returns the source address.
204-
pub fn src_uni_addr(&self) -> io::Result<Option<uni_addr::SocketAddr>> {
204+
pub fn src_uni_addr(&self) -> io::Result<Option<uni_addr::UniAddr>> {
205205
use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
206206

207207
match self {
208208
Self::Unspecified => Ok(None),
209-
Self::Inet { src_ip, src_port, .. } => Ok(Some(uni_addr::SocketAddr::Inet(SocketAddr::V4(
209+
Self::Inet { src_ip, src_port, .. } => Ok(Some(uni_addr::UniAddr::from(SocketAddr::V4(
210210
SocketAddrV4::new(*src_ip, *src_port),
211211
)))),
212-
Self::Inet6 { src_ip, src_port, .. } => Ok(Some(uni_addr::SocketAddr::Inet(SocketAddr::V6(
212+
Self::Inet6 { src_ip, src_port, .. } => Ok(Some(uni_addr::UniAddr::from(SocketAddr::V6(
213213
SocketAddrV6::new(*src_ip, *src_port, 0, 0),
214214
)))),
215215
#[cfg(unix)]
216216
Self::Unix { src_addr, .. } => uni_addr::unix::SocketAddr::from_bytes_until_nul(src_addr)
217-
.map(uni_addr::SocketAddr::Unix)
217+
.map(Into::into)
218218
.map(Some),
219-
#[cfg(not(unix))]
220-
Self::Unix { .. } => Err(io::Error::new(
221-
io::ErrorKind::Unsupported,
222-
"Unix socket addresses are not supported on this platform",
223-
)),
224219
}
225220
}
226221

227222
#[cfg(feature = "feat-uni-addr")]
228223
/// Returns the destination address.
229-
pub fn dst_uni_addr(&self) -> io::Result<Option<uni_addr::SocketAddr>> {
224+
pub fn dst_uni_addr(&self) -> io::Result<Option<uni_addr::UniAddr>> {
230225
use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
231226

232227
match self {
233228
Self::Unspecified => Ok(None),
234-
Self::Inet { dst_ip, dst_port, .. } => Ok(Some(uni_addr::SocketAddr::Inet(SocketAddr::V4(
229+
Self::Inet { dst_ip, dst_port, .. } => Ok(Some(uni_addr::UniAddr::from(SocketAddr::V4(
235230
SocketAddrV4::new(*dst_ip, *dst_port),
236231
)))),
237-
Self::Inet6 { dst_ip, dst_port, .. } => Ok(Some(uni_addr::SocketAddr::Inet(SocketAddr::V6(
232+
Self::Inet6 { dst_ip, dst_port, .. } => Ok(Some(uni_addr::UniAddr::from(SocketAddr::V6(
238233
SocketAddrV6::new(*dst_ip, *dst_port, 0, 0),
239234
)))),
240235
#[cfg(unix)]
241236
Self::Unix { dst_addr, .. } => uni_addr::unix::SocketAddr::from_bytes_until_nul(dst_addr)
242-
.map(uni_addr::SocketAddr::Unix)
237+
.map(Into::into)
243238
.map(Some),
244-
#[cfg(not(unix))]
245-
Self::Unix { .. } => Err(io::Error::new(
246-
io::ErrorKind::Unsupported,
247-
"Unix socket addresses are not supported on this platform",
248-
)),
249239
}
250240
}
251241
}
@@ -411,7 +401,7 @@ impl<'a> ExtensionRef<'a> {
411401
let Ok(len) = reader.read_u16() else {
412402
return Err(DecodeError::MalformedData);
413403
};
414-
let Ok(payload) = reader.take(len as usize) else {
404+
let Ok(payload) = reader.read(len as usize) else {
415405
return Err(DecodeError::MalformedData);
416406
};
417407

0 commit comments

Comments
 (0)