tls_client_hello_parser/
client_hello.rs1use rustls::{internal::msgs::base::PayloadU8, CipherSuite, SignatureScheme};
4
5pub struct ClientHello<'a> {
7 server_name: Option<webpki::DnsName>,
8 signature_schemes: &'a [SignatureScheme],
9 alpn: Option<&'a Vec<PayloadU8>>,
10 cipher_suites: &'a [CipherSuite],
11}
12
13impl<'a> ClientHello<'a> {
14 pub fn new(
15 server_name: Option<webpki::DnsName>,
16 signature_schemes: &'a [SignatureScheme],
17 alpn: Option<&'a Vec<PayloadU8>>,
18 cipher_suites: &'a [CipherSuite],
19 ) -> Self {
20 ClientHello {
21 server_name,
22 signature_schemes,
23 alpn,
24 cipher_suites,
25 }
26 }
27
28 pub fn server_name(&self) -> Option<&str> {
29 self.server_name
30 .as_ref()
31 .map(<webpki::DnsName as AsRef<str>>::as_ref)
32 }
33
34 pub fn signature_schemes(&self) -> &[SignatureScheme] {
35 self.signature_schemes
36 }
37
38 pub fn alpn(&self) -> Option<impl Iterator<Item = &'a [u8]>> {
39 self.alpn
40 .map(|protocols| protocols.iter().map(|proto| proto.0.as_slice()))
41 }
42
43 pub fn cipher_suites(&self) -> &[CipherSuite] {
44 self.cipher_suites
45 }
46}