Struct TlType

Source
pub struct TlType<'s> { /* private fields */ }
Expand description

A root (main) TLV writer.

Implementations§

Source§

impl<'s> TlType<'s>

Source

pub fn add_alpn<'a>( &mut self, alpns: impl Iterator<Item = &'a [u8]>, ) -> HaProxRes<()>

Adds the Application-Layer Protocol Negotiation (ALPN)

Source

pub fn add_noop(&mut self) -> HaProxRes<()>

Adds padding 3 bytes.

Source

pub fn add_netns(&mut self, ns: impl Into<String>) -> HaProxRes<()>

Adds US-ASCII string representation of the namespace’s name

Source

pub fn add_crc32(&mut self) -> HaProxRes<()>

Adds a 32-bit number storing the CRC32c checksum of the PROXY protocol header

It will be calculated after finalization.

Source

pub fn add_uniq_id<ID: PP2TlvUniqId>(&mut self, au: ID) -> HaProxRes<()>

Adds a uniqID. See PP2TlvUniqId. 128 bytes max.

Source

pub fn add_authority(&mut self, authority: impl Into<String>) -> HaProxRes<()>

Adds “SNI” i.e the “server_name” extension as defined by RFC3546.

Source

pub fn add_ssl( self, client: PP2TlvClient, verify: u32, ) -> HaProxRes<TlvSubTypeSsl<'s>>

Adds SSL properties.

Examples found in repository?
examples/example_custom_composer.rs (line 55)
46fn main()
47{
48    let addr = ProxyV2Addr::try_from(("127.0.0.1:39754", "127.0.0.67:11883")).unwrap();
49        
50    let mut comp = 
51        ProxyHdrV2::<HdrV2OpProxy>::new(ProxyTransportFam::STREAM, addr).unwrap();
52
53    let plts = comp.set_plts();
54
55    let mut ssl = plts.add_ssl(PP2TlvClient::PP2_CLIENT_SSL, 0).unwrap();
56
57    ssl.add_ssl_sub_version("TLSv1.2").unwrap();
58    
59    let mut plts = ssl.done().unwrap();
60
61
62    let cust_plt = ProxyV2Dummy2::SomeTlvName(0x01020304, 0x05060708);
63
64    plts.add_tlv(cust_plt, Some(&[0xE0..=0xE0])).unwrap();
65
66    drop(plts);
67
68    let pkt: Vec<u8> = comp.try_into().unwrap();
69
70    let ctrl = 
71b"\x0d\x0a\x0d\x0a\x00\x0d\x0a\x51\x55\x49\x54\x0a\x21\x11\x00\x29\
72\x7f\x00\x00\x01\x7f\x00\x00\x43\x9b\x4a\x2e\x6b\x20\x00\x0f\x01\
73\x00\x00\x00\x00\x21\x00\x07\x54\x4c\x53\x76\x31\x2e\x32\xE0\x00\
74\x08\x01\x02\x03\x04\x05\x06\x07\x08";
75
76    assert_eq!(pkt.as_slice(), ctrl.as_slice());
77}
Source

pub fn add_tlv<TLV: PP2TlvDump>( &mut self, tlv: TLV, opt_constr: Option<&'static [RangeInclusive<u8>]>, ) -> HaProxRes<()>

Adding external TLV. The adding instance should implement PP2TlvDump.

Examples found in repository?
examples/example_custom_composer.rs (line 64)
46fn main()
47{
48    let addr = ProxyV2Addr::try_from(("127.0.0.1:39754", "127.0.0.67:11883")).unwrap();
49        
50    let mut comp = 
51        ProxyHdrV2::<HdrV2OpProxy>::new(ProxyTransportFam::STREAM, addr).unwrap();
52
53    let plts = comp.set_plts();
54
55    let mut ssl = plts.add_ssl(PP2TlvClient::PP2_CLIENT_SSL, 0).unwrap();
56
57    ssl.add_ssl_sub_version("TLSv1.2").unwrap();
58    
59    let mut plts = ssl.done().unwrap();
60
61
62    let cust_plt = ProxyV2Dummy2::SomeTlvName(0x01020304, 0x05060708);
63
64    plts.add_tlv(cust_plt, Some(&[0xE0..=0xE0])).unwrap();
65
66    drop(plts);
67
68    let pkt: Vec<u8> = comp.try_into().unwrap();
69
70    let ctrl = 
71b"\x0d\x0a\x0d\x0a\x00\x0d\x0a\x51\x55\x49\x54\x0a\x21\x11\x00\x29\
72\x7f\x00\x00\x01\x7f\x00\x00\x43\x9b\x4a\x2e\x6b\x20\x00\x0f\x01\
73\x00\x00\x00\x00\x21\x00\x07\x54\x4c\x53\x76\x31\x2e\x32\xE0\x00\
74\x08\x01\x02\x03\x04\x05\x06\x07\x08";
75
76    assert_eq!(pkt.as_slice(), ctrl.as_slice());
77}

Trait Implementations§

Source§

impl<'s> Debug for TlType<'s>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s> Freeze for TlType<'s>

§

impl<'s> RefUnwindSafe for TlType<'s>

§

impl<'s> Send for TlType<'s>

§

impl<'s> Sync for TlType<'s>

§

impl<'s> Unpin for TlType<'s>

§

impl<'s> !UnwindSafe for TlType<'s>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.