1use haprox_rs::{ProtocolV1Inet, ProxyHdrV1, ProxyV1Parser};
2
3
4fn main()
5{
6 let res =
7 ProxyHdrV1::from_str("192.168.1.1:333", "127.0.0.1:444")
8 .unwrap();
9
10 let out = res.to_string();
11
12 println!("{}", out);
13
14 let pv1 =
15 ProxyV1Parser
16 ::try_from_str(out.as_str(), false)
17 .unwrap();
18
19 assert_eq!(pv1.get_inet(), ProtocolV1Inet::Tcp4);
20 assert_eq!(pv1.get_src_addr(), Some("192.168.1.1".parse().unwrap()));
21 assert_eq!(pv1.get_src_port(), Some(333));
22 assert_eq!(pv1.get_dst_addr(), Some("127.0.0.1".parse().unwrap()));
23 assert_eq!(pv1.get_dst_port(), Some(444));
24}