@@ -20,8 +20,9 @@ all() ->
2020
2121groups () -> [
2222 {sequential_tests , [], [
23- proxy_protocol ,
24- proxy_protocol_tls
23+ proxy_protocol_v1 ,
24+ proxy_protocol_v1_tls ,
25+ proxy_protocol_v2_local
2526 ]}
2627 ].
2728
@@ -54,7 +55,7 @@ init_per_testcase(Testcase, Config) ->
5455end_per_testcase (Testcase , Config ) ->
5556 rabbit_ct_helpers :testcase_finished (Config , Testcase ).
5657
57- proxy_protocol (Config ) ->
58+ proxy_protocol_v1 (Config ) ->
5859 Port = rabbit_ct_broker_helpers :get_node_config (Config , 0 , tcp_port_amqp ),
5960 {ok , Socket } = gen_tcp :connect ({127 ,0 ,0 ,1 }, Port ,
6061 [binary , {active , false }, {packet , raw }]),
@@ -68,7 +69,7 @@ proxy_protocol(Config) ->
6869 gen_tcp :close (Socket ),
6970 ok .
7071
71- proxy_protocol_tls (Config ) ->
72+ proxy_protocol_v1_tls (Config ) ->
7273 app_utils :start_applications ([asn1 , crypto , public_key , ssl ]),
7374 Port = rabbit_ct_broker_helpers :get_node_config (Config , 0 , tcp_port_amqp_tls ),
7475 {ok , Socket } = gen_tcp :connect ({127 ,0 ,0 ,1 }, Port ,
@@ -85,6 +86,25 @@ proxy_protocol_tls(Config) ->
8586 gen_tcp :close (Socket ),
8687 ok .
8788
89+ proxy_protocol_v2_local (Config ) ->
90+ ProxyInfo = #{
91+ command => local ,
92+ version => 2
93+ },
94+ Port = rabbit_ct_broker_helpers :get_node_config (Config , 0 , tcp_port_amqp ),
95+ {ok , Socket } = gen_tcp :connect ({127 ,0 ,0 ,1 }, Port ,
96+ [binary , {active , false }, {packet , raw }]),
97+ ok = inet :send (Socket , ranch_proxy_header :header (ProxyInfo )),
98+ [ok = inet :send (Socket , amqp_1_0_frame (FrameType ))
99+ || FrameType <- [header_sasl , sasl_init , header_amqp , open , 'begin' ]],
100+ {ok , _Packet } = gen_tcp :recv (Socket , 0 , ? TIMEOUT ),
101+ ConnectionName = rabbit_ct_broker_helpers :rpc (Config , 0 ,
102+ ? MODULE , connection_name , []),
103+ match = re :run (ConnectionName , <<" ^127.0.0.1:\\ d+ -> 127.0.0.1:\\ d+$" >>, [{capture , none }]),
104+ gen_tcp :close (Socket ),
105+ ok .
106+
107+
88108% % hex frames to send to have the connection recorded in RabbitMQ
89109% % use wireshark with one of the Java tests to record those
90110amqp_1_0_frame (header_sasl ) ->
0 commit comments