Skip to content

Commit 9edfd54

Browse files
authored
feat(tls): allow custom ALPN configuration (#921)
1 parent 362c12a commit 9edfd54

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/tls/conn/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl Inner {
224224
// Set ALPS protos
225225
if let Some(ref alps_values) = self.config.alps_protocols {
226226
for alps in alps_values.iter() {
227-
cfg.add_application_settings(alps.value())?;
227+
cfg.add_application_settings(alps.0)?;
228228
}
229229

230230
// By default, the old endpoint is used.

src/tls/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use bytes::{BufMut, Bytes, BytesMut};
3636

3737
/// A TLS protocol version.
3838
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
39-
pub struct TlsVersion(pub(super) ssl::SslVersion);
39+
pub struct TlsVersion(ssl::SslVersion);
4040

4141
impl TlsVersion {
4242
/// Version 1.0 of the TLS protocol.
@@ -66,13 +66,18 @@ impl AlpnProtocol {
6666
/// Prefer HTTP/3
6767
pub const HTTP3: AlpnProtocol = AlpnProtocol(b"h3");
6868

69+
/// Create a new [`AlpnProtocol`] from a static byte slice.
6970
#[inline]
70-
pub(crate) fn encode(self) -> Bytes {
71-
Self::encode_sequence(std::iter::once(&self))
71+
pub const fn new(value: &'static [u8]) -> Self {
72+
AlpnProtocol(value)
7273
}
7374

7475
#[inline]
75-
pub(crate) fn encode_sequence<'a, I>(items: I) -> Bytes
76+
fn encode(self) -> Bytes {
77+
Self::encode_sequence(std::iter::once(&self))
78+
}
79+
80+
fn encode_sequence<'a, I>(items: I) -> Bytes
7681
where
7782
I: IntoIterator<Item = &'a AlpnProtocol>,
7883
{
@@ -98,11 +103,6 @@ impl AlpsProtocol {
98103

99104
/// Prefer HTTP/3
100105
pub const HTTP3: AlpsProtocol = AlpsProtocol(b"h3");
101-
102-
#[inline]
103-
pub(crate) const fn value(self) -> &'static [u8] {
104-
self.0
105-
}
106106
}
107107

108108
#[cfg(test)]

0 commit comments

Comments
 (0)