@@ -1473,32 +1473,17 @@ handle_frame_pre_auth(Transport,
14731473 VirtualHost ,
14741474 {socket , S },
14751475 #{}),
1476- AdvertisedHost =
1477- case TransportLayer of
1478- tcp ->
1479- rabbit_stream :host ();
1480- ssl ->
1481- rabbit_stream :tls_host ()
1482- end ,
1483- AdvertisedPort =
1484- case TransportLayer of
1485- tcp ->
1486- rabbit_data_coercion :to_binary (
1487- rabbit_stream :port ());
1488- ssl ->
1489- rabbit_data_coercion :to_binary (
1490- rabbit_stream :tls_port ())
1491- end ,
14921476
1493- ConnectionProperties =
1494- #{<<" advertised_host" >> => AdvertisedHost ,
1495- <<" advertised_port" >> => AdvertisedPort },
1477+ AdHost = advertised_host (TransportLayer ),
1478+ AdPort = rabbit_data_coercion :to_binary (advertised_port (TransportLayer )),
1479+ ConnProps = #{<<" advertised_host" >> => AdHost ,
1480+ <<" advertised_port" >> => AdPort },
14961481
14971482 ? LOG_DEBUG (" sending open response ok ~ts " , [VirtualHost ]),
14981483 Frame =
14991484 rabbit_stream_core :frame ({response , CorrelationId ,
15001485 {open , ? RESPONSE_CODE_OK ,
1501- ConnectionProperties }}),
1486+ ConnProps }}),
15021487
15031488 send (Transport , S , Frame ),
15041489 % % FIXME check if vhost is alive (see rabbit_reader:is_vhost_alive/2)
@@ -2337,13 +2322,10 @@ handle_frame_post_auth(Transport,
23372322 Nodes0 ),
23382323 NodeEndpoints =
23392324 lists :foldr (fun (Node , Acc ) ->
2340- PortFunction =
2341- case TransportLayer of
2342- tcp -> port ;
2343- ssl -> tls_port
2344- end ,
2345- Host = rpc :call (Node , rabbit_stream , host , []),
2346- Port = rpc :call (Node , rabbit_stream , PortFunction , []),
2325+ HostFun = advertised_host_fun (TransportLayer ),
2326+ PortFun = advertised_port_fun (TransportLayer ),
2327+ Host = rpc :call (Node , rabbit_stream , HostFun , []),
2328+ Port = rpc :call (Node , rabbit_stream , PortFun , []),
23472329 case {is_binary (Host ), is_integer (Port )} of
23482330 {true , true } -> Acc #{Node => {Host , Port }};
23492331 _ ->
@@ -4077,3 +4059,21 @@ retry_sac_call(Call, N) ->
40774059 R ->
40784060 R
40794061 end .
4062+
4063+ advertised_host (Transport ) ->
4064+ F = advertised_host_fun (Transport ),
4065+ rabbit_stream :F ().
4066+
4067+ advertised_port (Transport ) ->
4068+ F = advertised_port_fun (Transport ),
4069+ rabbit_stream :F ().
4070+
4071+ advertised_host_fun (tcp ) ->
4072+ host ;
4073+ advertised_host_fun (ssl ) ->
4074+ tls_host .
4075+
4076+ advertised_port_fun (tcp ) ->
4077+ port ;
4078+ advertised_port_fun (ssl ) ->
4079+ tls_port .
0 commit comments