@@ -608,6 +608,19 @@ TEST_P(ProxyProtocolTest, V2ShortV4) {
608
608
expectProxyProtoError ();
609
609
}
610
610
611
+ TEST_P (ProxyProtocolTest, V2ShortV4WithAllowNoProxyProtocol) {
612
+ // An ipv4/tcp connection that has incorrect addr-len encoded
613
+ constexpr uint8_t buffer[] = {0x0d , 0x0a , 0x0d , 0x0a , 0x00 , 0x0d , 0x0a , 0x51 , 0x55 , 0x49 ,
614
+ 0x54 , 0x0a , 0x21 , 0x21 , 0x00 , 0x04 , 0x00 , 0x08 , 0x00 , 0x02 ,
615
+ ' m' , ' o' , ' r' , ' e' , ' ' , ' d' , ' a' , ' t' , ' a' };
616
+ envoy::extensions::filters::listener::proxy_protocol::v3::ProxyProtocol proto_config;
617
+ proto_config.set_allow_requests_without_proxy_protocol (true );
618
+ connect (false , &proto_config);
619
+
620
+ write (buffer, sizeof (buffer));
621
+ expectProxyProtoError ();
622
+ }
623
+
611
624
TEST_P (ProxyProtocolTest, V2ShortAddrV4) {
612
625
// An ipv4/tcp connection that has insufficient header-length encoded
613
626
constexpr uint8_t buffer[] = {0x0d , 0x0a , 0x0d , 0x0a , 0x00 , 0x0d , 0x0a , 0x51 , 0x55 , 0x49 ,
@@ -691,6 +704,18 @@ TEST_P(ProxyProtocolTest, V1TooLong) {
691
704
expectProxyProtoError ();
692
705
}
693
706
707
+ TEST_P (ProxyProtocolTest, V1TooLongWithAllowNoProxyProtocol) {
708
+ constexpr uint8_t buffer[] = {' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' };
709
+ envoy::extensions::filters::listener::proxy_protocol::v3::ProxyProtocol proto_config;
710
+ proto_config.set_allow_requests_without_proxy_protocol (true );
711
+ connect (false , &proto_config);
712
+ write (" PROXY TCP4 1.2.3.4 2.3.4.5 100 100" );
713
+ for (size_t i = 0 ; i < 256 ; i += sizeof (buffer)) {
714
+ write (buffer, sizeof (buffer));
715
+ }
716
+ expectProxyProtoError ();
717
+ }
718
+
694
719
TEST_P (ProxyProtocolTest, V2ParseExtensions) {
695
720
// A well-formed ipv4/tcp with a pair of TLV extensions is accepted
696
721
constexpr uint8_t buffer[] = {0x0d , 0x0a , 0x0d , 0x0a , 0x00 , 0x0d , 0x0a , 0x51 , 0x55 , 0x49 ,
0 commit comments